/*
	Function Name:	logOut
	@purpose: To logout the logged user.	
*/

function logOut(){
	window.parent.parent.location.href='/index.php?option=com_comprofiler&task=logout&lang=en'		
}
var urlset = 0;
function flashPopup(html, x, y, width, height) {
if(urlset>1){
urlset = 0;
} 
	 //alert(html);
	/* Set the left margin based on the screen resolution */
	//for hide back button on the top 
	if(html == 'http://www.cstorelife.com/popup/left.php' 
  || html == 'http://www.cstorelife.com/popup/middle.php' 
  || html == 'http://www.cstorelife.com/popup/right.php'
  || html == 'http://www.cstorelife.com/index.php?option=com_games&task=show_score_board&tmpl=component'
  || html == 'http://www.cstorelife.com/popup/showballfight Feb 28 2/showballfight Feb 28/index.php'
  || html == 'http://www.cstorelife.com/popup/picture stack gallery demo/index.html'
  || html == 'http://www.cstorelife.com/popup/contraband/contraband/contraband.html'
  || html == 'http://www.cstorelife.com/popup/educationalwall/educationalwall/index.html'
  || html == 'http://www.cstorelife.com/index.php?option=com_registration&task=open_imperial'
  || html == 'http://www.cstorelife.com/popup/backtofront.html'
  || html == 'http://www.cstorelife.com/popup/outdoor.html'
  || html == 'http://www.cstorelife.com/popup/office.html'
  || html == 'http://www.cstorelife.com/popup/coldvault.html'
  || html == 'http://www.cstorelife.com/popup/Mars Cooler/index.html'
  || html == 'http://www.cstorelife.com/popup/bathroom.html'
  || html == 'http://www.cstorelife.com/popup/s3.html'
  || html == 'http://www.cstorelife.com/popup/backleft.html'
  || html == 'http://www.cstorelife.com/popuppopup/picture stack gallery demo/index.html'
  || html == 'http://www.cstorelife.com/popup/new_products/index.php'
  || html == 'http://www.cstorelife.com//index.php?option=com_games&task=show_my_score_board&tmpl=component'
  || html == 'http://www.cstorelife.com/popup/s1.html'
  || html == 'http://www.cstorelife.com/popup/final_free_my_beer/index.html'
  || html == 'http://www.cstorelife.com/popup/coloring-book/index.html'
  )
  {
  
  document.getElementById('div_back').style.display	='none';
  }else{
   document.getElementById('div_back').style.display	='block';
  }
	initial_width	=	width;
	initial_height	=	height;
	var iframe = document.getElementById('iframe');
	var div = document.getElementById('divFrame');
	iframe.style.display	=	'block';
	var div_black  = document.getElementById('div_black');
	var div_iframe = document.getElementById('div_iframe');	
	var div_close  = document.getElementById('div_close');
	div.style.display	='block';
	div_close.style.display	='block';
	if (y == "imperial") {
		height	=	670;
		width	=	880;		 
	}
	
	main_frame_width	=	1110;	
	var Screenleft = parseInt((parseInt(main_frame_width)/2));	
	var Divhalfwidth = parseInt((parseInt(width))/2); //Measuring half of main div (in pixels).
	var exactLeft = parseInt(parseInt(Screenleft) - parseInt(Divhalfwidth)); //Measuring exact distance from left.
	

	
	
	if(exactLeft<100){
	//alert('100');
		exactLeft	=	exactLeft-exactLeft/2+25;
	}
if(initial_width==640 && initial_height==480){
//alert('640');
	exactLeft	=	exactLeft;
}
if(x=='survey'){
	exactLeft	=	93;
}
	div.style.left = exactLeft+'px';
	
	div_black_height	=	height+30;
	div_black_width		=	width;
	div_iframe_height	=	height;
	div_iframe_width	=	width;
	
	if(initial_width==640 && initial_height==480){
		
		div_black_width		=	640;
		div_black_height	=	480;
		
		div_iframe_width	=	640;
		div_iframe_height	=	480;
	}
	div_black.style.height	=	div_black_height;
	div_black.style.width	=	div_black_width;
	
	div_iframe.style.height	=	div_iframe_height;
	div_iframe.style.width	=	div_iframe_width;
	
	iframe.src = html;
	iframe.width = width;
	iframe.height = height;			
}

function callImperial(html, x, y, width, height) {
	//alert('Imperial');
	/* Set the left margin based on the screen resolution */
	clicky.log('/index.php',"Imperial Tobacco");
	//alert("Imperial  Logged Successfull.");
	var iframe = document.getElementById('iframe_imperial');
	iframe.style.display	=	'block';
	var div = document.getElementById('divFrame');
	
	var div_black  = document.getElementById('div_black');
	var div_iframe = document.getElementById('div_iframe');	
	var div_close  = document.getElementById('div_close');
	div.style.display	='block';
	div_close.style.display	='block';
	if (y == "imperial") {		
		height=670;
		width=1011;		 
	}
	
	main_frame_width	=	1170;	
	var Screenleft = parseInt((parseInt(main_frame_width)/2));	
	var Divhalfwidth = parseInt((parseInt(width))/2); //Measuring half of main div (in pixels).
	var exactLeft = parseInt(parseInt(Screenleft) - parseInt(Divhalfwidth)); //Measuring exact distance from left.
	

	
	
	if(exactLeft<100){
		exactLeft	=	exactLeft-exactLeft/2;
	}
	div.style.left = exactLeft+'px';
	
	div_black_height	=	height+30;
	div_black_width		=	width;
	div_iframe_height	=	height;
	div_iframe_width	=	width;
	
	div_black.style.height	=	div_black_height;
	div_black.style.width	=	div_black_width;
	
	div_iframe.style.height	=	div_iframe_height;
	div_iframe.style.width	=	div_iframe_width;
	
	iframe.src = html;
	iframe.width = width;
	iframe.height = height;			
}
function flashPopup1(html, x, y, width, height) {
		
	/* Set the left margin based on the screen resolution */
	    
	var iframe = document.getElementById('iframe1');
	iframe.style.display	=	'block';
	var div = document.getElementById('divFrame1');
	
	var div_black  = document.getElementById('div_black1');
	var div_iframe = document.getElementById('div_iframe1');	
	var div_close  = document.getElementById('div_close_employment1');
	div_close.style.display	='block';
	div.style.display	='block';
	
	if (y == "imperial") {		
		height=670;
		width=880;		 
	}
	
	main_frame_width	=	1110;	
	var Screenleft = parseInt((parseInt(main_frame_width)/2));	
	var Divhalfwidth = parseInt((parseInt(width))/2); //Measuring half of main div (in pixels).
	var exactLeft = parseInt(parseInt(Screenleft) - parseInt(Divhalfwidth)); //Measuring exact distance from left.
	

	
	
	if(exactLeft<100){
		exactLeft	=	exactLeft-exactLeft/2;
	}
	div.style.left = exactLeft+'px';
	
	div_black_height	=	height+30;
	div_black_width		=	width;
	div_iframe_height	=	height;
	div_iframe_width	=	width;
	
	div_black.style.height	=	div_black_height;
	div_black.style.width	=	div_black_width;
	
	div_iframe.style.height	=	div_iframe_height;
	div_iframe.style.width	=	div_iframe_width;
	
	iframe.src = html;
	iframe.width = width;
	iframe.height = height;			
}
function show_games_videos(html, x, y, width, height){	
	var iframe = document.getElementById('iframe_games_videos');
	var div = document.getElementById('div_games_videos');
	div.style.display	='block';
	iframe.src = html;	
}
function close_popup_reg(){
	
	//document.getElementById('flashpopup').sendTextFromHtml();	
	flashPopup('',0,0,0,0);
	callImperial('',0,0,0,0);
	var iframe          		=   document.getElementById('iframe');

	iframe.style.display		=   'none';
	var iframe_imperial          	=   document.getElementById('iframe_imperial');

	iframe_imperial.style.display	=   'none';
	iframe.scrolling    		=   "NO";
	//Hide the frame
	var div = document.getElementById('divFrame');	
	div.style.display		=	'none';		
	//Hide the back button
	div_back_button	=	document.getElementById('div_back_button');
	div_back_button.style.display	=	'none';
	
	//Close the game/video
	var div_games_videos 		=	document.getElementById('div_games_videos');
	var iframe_games_videos		=	document.getElementById('iframe_games_videos');
	iframe_games_videos.style.display		=   'none';
	iframe_games_videos.src 	= '';	
	div_games_videos.style.display	='none';
	return false;
}

function close_popup(urltest){
   urlset = urlset + 1;
 //alert(urlset);
	//document.getElementById('flashpopup').sendTextFromHtml();	
	if(urlset==1)
	{
  flashPopup(urltest,0,0,880,680);
  }else{
  flashPopup('',0,0,0,0);
	callImperial('',0,0,0,0);
	var iframe          		=   document.getElementById('iframe');

	iframe.style.display		=   'none';
	var iframe_imperial          	=   document.getElementById('iframe_imperial');

	iframe_imperial.style.display	=   'none';
	iframe.scrolling    		=   "NO";
	//Hide the frame
	var div = document.getElementById('divFrame');	
	div.style.display		=	'none';		
	//Hide the back button
	div_back_button	=	document.getElementById('div_back_button');
	div_back_button.style.display	=	'none';
	
	//Close the game/video
	var div_games_videos 		=	document.getElementById('div_games_videos');
	var iframe_games_videos		=	document.getElementById('iframe_games_videos');
	iframe_games_videos.style.display		=   'none';
	iframe_games_videos.src 	= '';	
	div_games_videos.style.display	='none';
	return false;
	}
}

/*
Function Name:close_popup_employment
Purpose: To close the popup for the 
*/
function close_popup_employment(){
	//Hide the frame
	var div = document.getElementById('divFrame1');	
	div.style.display		=	'none';		
	//Hide the close button
	div_close_button		=	document.getElementById('div_close_employment1');
	div_close_button.style.display	=	'none';	
	
	not_employed_confirmed_value	=	document.getElementById('not_employed_confirmed').value;
	
	if(not_employed_confirmed_value==1){
		logOut();
	}
}



function newBackPopup(){
	var div_back_button 	= document.getElementById('div_backbut');	
	div_back_button.style.display	='none';
	flashPopup('/popup/cstorewall/cstorewall/index.html',0,0,880,710);
}


function jackHome(){
	var div_back_button 	= document.getElementById('div_back_button');	
	div_back_button.style.display	='none';
	flashPopup('/popup/jack_menu.php',0,0,820,540);
}


function hide_frame(){
	var div = document.getElementById('divFrame');	
	div.style.display	=	'none';				
}
