/** 
 * JS Utilities for PlayStaion Freedom
 */


 /* re-usable popup windows */
 var popWin;
 
 
  /* */
 function popVoucher(){
 	var props = {
		width:       770,
		height:      570,
		scrollbars:  'yes',
		resizable:   'yes',
		toolbar:     'no',
		location:    'no',
		menubar:     'no',
		directories: 'no',
		status:      'no',
		titlebar:    'no',
		dependent:   'no',
		modal:       'no'
	};
	doPop('/popup/voucher.htm', props);
 }
 
 
   /* */
 function terms_koif(){
 	var props = {
		width:       400,
		height:      450,
		scrollbars:  'yes',
		resizable:   'yes',
		toolbar:     'no',
		location:    'no',
		menubar:     'no',
		directories: 'no',
		status:      'no',
		titlebar:    'yes',
		dependent:   'no',
		modal:       'no'
	};
	doPop('/koif/tandc/', props);
 }
 
 
 /* */
 function popHelp(lnk){
 	var props = {
		width:       550,
		height:      400,
		scrollbars:  'yes',
		resizable:   'yes',
		toolbar:     'yes',
		location:    'no',
		menubar:     'yes',
		directories: 'no',
		status:      'yes',
		titlebar:    'no',
		dependent:   'no',
		modal:       'no'
	};
	doPop('/popup/help.htm#'+lnk, props);
 }
 
 
 /* */
 function sendFriend(url){
 	var props = {
		width:       400,
		height:      450,
		scrollbars:  'yes',
		resizable:   'yes',
		toolbar:     'no',
		location:    'no',
		menubar:     'yes',
		directories: 'no',
		status:      'yes',
		titlebar:    'no',
		dependent:   'yes',
		modal:       'no'
	};
	if(url == null){
		url = document.location.href;
	}
	doPop('/sendfriend.php?url='+escape(url), props);
 }
 
 
 
 /* */
 function popUploadBlog(blogID){
 	//alert(blogID);
 	var props = {
		width:       400,
		height:      450,
		scrollbars:  'yes',
		resizable:   'yes',
		toolbar:     'no',
		location:    'no',
		menubar:     'yes',
		directories: 'no',
		status:      'yes',
		titlebar:    'no',
		dependent:   'yes',
		modal:       'no'
	};
	if(blogID == null){
		doPop('/upload/video.php', props);
 	}else{
		doPop('/upload/video.php?blogID='+blogID, props);
 	}
 }
 
 
 
 /* */
 function popUploadAvatar(){
 	var props = {
		width:       350,
		height:      300,
		scrollbars:  'yes',
		resizable:   'yes',
		toolbar:     'no',
		location:    'no',
		menubar:     'yes',
		directories: 'no',
		status:      'yes',
		titlebar:    'no',
		dependent:   'yes',
		modal:       'no'
	};
	doPop('/upload/avatar.php', props);
 }

 

 /* */ 
 function popLegals(path){
 	var props = {
		width:      600,
		height:     400,
		scrollbars:  'yes',
		resizable:   'yes',
		toolbar:     'no',
		location:    'no',
		menubar:     'yes',
		directories: 'no',
		status:      'yes'
	};
	doPop(path, props);
 }
 
 
 
 
 /* */
 function doPop(path, props){
 	// serialize props
	if(typeof props == 'object'){
		arrprops = [];
		for(var p in props){
			arrprops[arrprops.length] = p + '=' + props[p].toString();
		}
		props = arrprops.join(',');
	}
 	if(typeof popWin == 'object' && !popWin.closed){
		// window is currently open
		// need to close to completely re-configure
		popWin.close();
		setTimeout("doPop('"+path+"','"+props+"')", 100);
	}else{
		// new window
		popWin = window.open(path, 'popWin', props);
		popWin.focus();
	}
 }

 
 /* */ 
 function unloadWin(){
 	if(typeof popWin == 'object' && !popWin.closed){
		popWin.close();
	}
 }
 
