function popup(pop_url, winname, windowWidth, windowHeight, scrollbars, resizable) {
	try {
		win.close();
	}catch(e){		
	}        		
	win = window.open(pop_url,winname,"scrollbars="+scrollbars+",width="+windowWidth+",height="+windowHeight+",resizable="+resizable);
	win.focus();
}
	
// this is the replace function
function stringReplace(originalString, findText, replaceText){
	var pos=0;
	var len=findText.length;
	pos=originalString.indexOf(findText);
	while(pos!=-1){
		preString = originalString.substring(0,pos);
		postString = originalString.substring(pos+len, originalString.length);
		originalString = preString + replaceText + postString;
		pos = originalString.indexOf(findText);
	}
	return originalString;
}	
	
	function QueryString(key) {
		var value = null;
		for (var i=0;i<QueryString.keys.length;i++)
			if (QueryString.keys[i]==key) {
				value = QueryString.values[i];
				break;
			}
		return value;
	}
	QueryString.keys = new Array();
	QueryString.values = new Array();

	function QueryString_Parse() {
		var query = unescape(window.location.search.substring(1) );
		var pairs = query.split("&");
		for (var i=0;i<pairs.length;i++) {
			var pos = pairs[i].indexOf('=');
			if (pos >= 0) {
				var argname = pairs[i].substring(0,pos);
				var value = pairs[i].substring(pos+1);
				QueryString.keys[QueryString.keys.length] = argname;
				QueryString.values[QueryString.values.length] = value;		
			}
		}
	}

	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
function openPopup( theURL, winName, features ) { 
		try {
			win.close();
		}catch(e){		
		}		
	   	win = window.open( theURL, winName, features ); 
		win.focus();
	} 

	function CookieStuff() {
		var ok = null;
		QueryString_Parse();
		var agecheck = unescape(QueryString("agecheck") );
		var cookie = readCookie('agecheck');
		if (cookie) {
			return cookie;
		} else if (agecheck == 'ok') {
			document.cookie = 'agecheck=ok; path=/';
			document.write(document.cookie);
			location.replace(document.location);
		} else if (agecheck == 'ng') {
			document.cookie = 'agecheck=ng; path=/';
			document.write(document.cookie);
			location.replace(document.location);
		} 
	}
	//order now
	function openOrder() { 
		width = 800;
		height = 600;
		try {
			newWindow.close();
		}catch(e){		
		}		
		newWindow = window.open('http://switch.atdmt.com/action/stayalivews_bestbuy','Order_Now','width=' + width + ',height=' + height + ',top=100,left=100,resizable=yes,status=yes,scrollbars=yes,location=yes,menubar=yes,toolbar=yes' + '');
		newWindow.focus();
		return;
	}
	//clips
		function openClip1() { 
		width = 714;
		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('clips/clip1.html','clips','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 
	//
	function openClip2() { 
		width = 714;
		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('clips/clip2.html','clips','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 
	//
	function openClip3() { 
		width = 714;
		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('clips/clip3.html','clips','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 
	//
	function openClip4() { 
		width = 714;
		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('clips/clip4.html','clips','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 
	//
	function openClip5() { 
		width = 714;
		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('clips/clip5.html','clips','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 
	//
	function openClip6() { 
		width = 714;
		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('clips/clip6.html','clips','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 
	//
	function openClip7() { 
		width = 714;
		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('clips/clip7.html','clips','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 
	//
	function openClip8() { 
		width = 714;
		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('clips/clip8.html','clips','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 
	//
	function openAIM() { 
		width = 714;
		height = 464;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('downloads/aim.html','AIM_Icons','width=' + width + ',height=' + height + ',top=100,left=100,resize=no,scrollbars=no' + '');
		newWindow.focus();
		return;
	} 

	function openMovie(num) {
		try {
			newWindow.close();
		}catch(e){		
		}			newWindow=window.open('downloads/movieclips/movie'+num+'/index.html','Movie','width=715,height=495,top=100,left=100' + '');
		newWindow.focus();
	}

	function openAaltoAIM() { 
		width = 502;
		height = 522;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('downloads/aalto_aim.html','AIM_Icons','width=' + width + ',height=' + height + ',top=100,left=100' + '');
		newWindow.focus();
		return;
	}

	function openTrailer() { 
			try {
				newWindow.close();
			}catch(e){		
			}		
            newWindow = window.open("trailer/trailer1.html","Trailer","width= 714,height= 494,top=100,left=100,scrollbars=no");
            newWindow.focus();
            return;
      } 

	function openSneakPeek() { 
   		width = 714;
  		height = 494;
		try {
			newWindow.close();
		}catch(e){		
		}			
  	 	newWindow = window.open('downloads/sneakPeak/sneakPeak.html','SneakPeek','width=' + width + ',height=' + height + ',top=100,left=100,scrollbars=0' + '');
   		newWindow.focus();
   		return;
 	} 

	function openWallpaper(size, name, wpname) { 
		width = 800;
		height = 500;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('downloads/wallpaper.html?size=' + size + '&name=' + name + '&wpname=' + wpname + '','Desktops','width=' + width + ',height=' + height + ',top=100,left=100,scrollbars=1' + '');
		newWindow.focus();
		return;
	} 

	function openIntWallpaper(platform) { 
		width = 400;
		height = 200;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('downloads/IntWallpaper.html?platform=' + platform + '','Interactive_Wallpaper','width=' + width + ',height=' + height + ',top=100,left=100' + '');
		newWindow.focus();
		return;
	} 

	function openScreensaver(platform) { 
		width = 400;
		height = 200;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('downloads/screensaver.html?platform=' + platform + '','Screensaver','width=' + width + ',height=' + height + ',top=100,left=100' + '');
		newWindow.focus();
		return;
	} 

	function openPoster() { 
		width = 620;
		height = 600;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('downloads/Poster.html','Poster','width=' + width + ',height=' + height + ',top=100,left=100' + '');
		newWindow.focus();
		return;
	} 

	function openIpod() { 
		width = 400;
		height = 200;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('ipod.html','iPod','width=' + width + ',height=' + height + ',top=100,left=100' + '');
		newWindow.focus();
		return;
	} 

	function openCharGen() {
		width = 726;
		height = 599;
		try {
			newWindow.close();
		}catch(e){		
		}			
		newWindow = window.open('charGen.html','charGen','width=' + width + ',height=' + height + ',top=100,left=100' + '');
		newWindow.focus();
		return;
	} 

	function closeMe() {
		window.close();
	}

	function initiateDownload(file) {
		window.location.href = file;
	}

	function getPath() {
		myString = new String(location.href)
		rExp = /AIM.html/gi;
		newString = new String ("img/aim/")
		path = myString.replace(rExp, newString)
		return(path);
	}
