// PopUp Window Script 
// popUp(url,width,height) - Create popup Window based on the provided width and heigth and centers it on the screen

	function popUp(URL,w,h) {
		day = new Date();
		id = day.getTime();
		
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
		
		var settings ='height='+h+',';
		settings +='width='+w+',';
		settings +='top='+wint+',';
		settings +='left='+winl+',';
		
		settings += 'toolbar=0';
		settings += 'scrollbars=0';
		settings += 'location=0';
		settings += 'statusbar=0';
		settings += 'menubar=0';
		settings += 'resizable=0';
		
		
		eval("page" + id + " = window.open(URL, '" + id + "', settings);");
	
	}
	
	// popUp(url,width,height) - Create popup Window based on the provided width and heigth and centers it on the screen

	function popUpResize(URL,w,h) {
		day = new Date();
		id = day.getTime();
		
		var winl = (screen.width-w)/2;
		var wint = (screen.height-h)/2;
		
		var settings ='height='+h+',';
		settings +='width='+w+',';
		settings +='top='+wint+',';
		settings +='left='+winl+',';
		
		settings += 'toolbar=0';
		settings += 'scrollbars=0';
		settings += 'location=0';
		settings += 'statusbar=0';
		settings += 'menubar=0';
		settings += 'resizable=1';
		
		
		eval("page" + id + " = window.open(URL, '" + id + "', settings);");
	
	}

// PopUp Picture

	function PopupPic(sPicURL){ 
		window.open( "http://www.kimartialarts.net/home/galleries/popupPic.php?"+sPicURL, "",  
		"resizable=1,WIDTH=300,HEIGHT=300"); 
	}

	var arrTemp=self.location.href.split("?"); 
	var picUrl = (arrTemp.length>0)?arrTemp[1]:""; 
  	var NS = (navigator.appName=="Netscape")?true:false; 

     function FitPic(){ 
		iWidth = (NS)?window.innerWidth:document.documentElement.clientWidth; 
		iHeight = (NS)?window.innerHeight:document.documentElement.clientHeight; 
		iWidth = document.images[0].width - iWidth; 
		iHeight = document.images[0].height - iHeight; 
		window.resizeBy(iWidth, iHeight); 
		self.focus(); 
     }

	// PopUp YouTube
	//
	//  VideoID = YouTube VideoID (See Examples)
	//  w = Width
	//	h = Height 
	//
	// 	Example YouTube ID:
	//		<param name="movie" value="http://www.youtube.com/v/aRKAWSyS4JA&hl=en&fs=1&color1=0x2b405b&color2=0x6b8ab6&border=1">
	//		<a href="javascript:PopupYoutube('aRKAWSyS4JA',580,365)">Video2</a>
	
	//		<param name="movie" value="http://www.youtube.com/v/F5ZCqsZiR-Q&hl=en&fs=1&rel=0&color1=0x2b405b&color2=0x6b8ab6">     
	// 		<a href="javascript:PopupYoutube('F5ZCqsZiR-Q',580,365)">KI-Martial Arts Tournament Board Breaking</a>) 

	function PopupYoutube(VideoId,w,h){
			popUp("http://www.kimartialarts.net/home/galleries/videobox.php?VideoId="+VideoId+"&VideoWidth="+w+"&VideoHeight="+h,w,h);
		
	}
		
	// MediaBox Media Player PopUp
	// Torbeck Innovations MediaBox Media Player (Based on FlowPlayer Open Source Project http://flowplayer.org)
	//
	//	MediaURL = URL of Video, MP3, or Picture
	//  w = Width
	//	h = Height 
	// 
	
   	function MediaBox(MediaURL,w,h) 
	{
		popUp("mediabox.php?MediaURL="+MediaURL+"&Width="+w+"&Height="+h,w,h);
	}


	function MBJukebox(playlist) 
	{
		// Coming Soon
	}
	
	// Photo Galleries
	// The photo gallery scripts (photogallery and flickergallery) require the use of tiltviewer.

		// photogallery (galleryname, xmlurl, maxJPGsize, colums, rows, style)
		//	galleryname 	= Name of Photo Gallery.
		//	xmlurl			= Path and Name of Galleries XML file. File lists information on each file in gallery.
		//	maxJPGsize		= Largest dimension (width or height) of your largest image. Used to proportionately scale your images to fit. 
		//	columns/rows 	= number of columns and rows.
		//  style			= Photo Gallery Style "tilt" = tiltview / "postcard" = postcard
	
		// flickrgallery (galleryname, user_id, tags, tag_mode, colums, rows)
		//	galleryname = Name of Photo Gallery.
		//  user_id 	= www.flickr.com user ID# ( Go to http://www.flickr.com/services/api/explore/?method=flickr.test.null) to get id.
		//	tags		= A comma-delimited list of flickr tags. Photos with one or more of the tags listed will be returned.	
		//	tag_mode 	= ("any" or "all") tags.
		//	columns/rows = number of columns and rows.	
	
	function photogallery(galleryname, xmlurl, maxJPGsize, columns, rows, style)
	{
		var winW = (screen.width*.75);
		var winH = (screen.height*.75);
		
		popUpResize("http://www.kimartialarts.net/home/galleries/photogallery.php?galleryname="+galleryname
			  +"&xmlurl="+xmlurl
			  +"&maxJPGsize="+maxJPGsize
			  +"&columns="+columns+"&rows="+rows
			  +"&style="+style,winW,winH);
	}
	
	function flickrgallery(galleryname, user_id, tags, tag_mode, columns, rows)
	{
		var winW = (screen.width*.75);
		var winH = (screen.height*.75);
		
		popUpResize("http://www.kimartialarts.net/home/galleries/fphotogallery.php?galleryname="+galleryname
			  +"&user_id="+user_id
			  +"&tags="+tags
			  +"&tag_mode="+tag_mode
			  +"&columns="+columns+"&rows="+rows,winW,winH);
	}
	


