//page global variables
var window_width, window_height;

//function to get page dimensions
function getPageDimensions() {
	window_width = (document.all) ? document.body.clientWidth : window.innerWidth;
	window_height = (document.all) ? document.body.clientHeight : window.innerHeight;
}

//function get xy (returns string for pop up properties
function getWinXY (win_width,win_height) {
	
		var screen_width = screen.availWidth;
		var screen_height = screen.availHeight;
		
		var xpos = Math.round(((screen_width - win_width)/2));
		var ypos = Math.round(((screen_height - win_height)/2));	

		if (document.layers) return ",screenX=" + xpos + ",screenY=" + ypos;
		else return ",left=" + xpos + ",top=" + ypos;
		
}


//rollover functions
function roll(lyr_ref,img_name,img_ref,status) {
	var src_file_name = (status == 'off') ? (img_name + '.gif') : (img_name + '_' + status + '.gif');
	var target_name = img_name + img_ref;
	var lyr_ref = (document.layers) ? (lyr_ref) : ('');
	//window.alert ('"images/' + src_file_name + '"');
	eval(lyr_ref + 'document.' + target_name + '.src = "' + base_path + 'images/' + src_file_name + '"');
}

//futura shop popup function
function popFuturaShop() {
	
	//set width and heights for popup
	var win_width=490 ;
	var win_height=430;
	
	//determine x y pos of centered window base on width and height
	//called from general_functions.js
	var win_pos = getWinXY(win_width,win_height);
	
	//open window
	window.open(base_path + 'futura_shop.asp','futura_shop','width='+win_width+',height=' + win_height + win_pos + ',scrollbars=no,resizable=no');
	
}

//futura sell through function
function popSellThrough() {
	
	//set width and heights for popup
	var win_width=410 ;
	var win_height=310;
	
	//determine x y pos of centered window base on width and height
	//called from general_functions.js
	var win_pos = getWinXY(win_width,win_height);
	
	//open window
	window.open(base_path + 'sell_through.asp','sell_through','width='+win_width+',height=' + win_height + win_pos + ',scrollbars=no,resizable=no');
	
}

//function to ensure frame based pages are in frameset
function frameEnforcer (location_object) {
	//window.alert('frame enforcer enabled');
	
	//if view product details popup
	if (location_object.href.indexOf('view_product_details.asp') > -1) {
		//window.alert (base_path + 'set_page_status.asp?page_name=product_line.asp?product_line_id=' + product_line_id);
		if (!window.opener) document.location.href = (base_path + 'set_page_status.asp?page_name=product_line.asp?product_line_id=' + product_line_id);
	}
	//if the page is not in frameset then redirect to appropriate frameset
	else if(top.frames.length == 0) {
		if (location_object.href.indexOf('cart.asp') > -1) document.location.href = (base_path + 'index.asp');
		else document.location.href = (base_path + 'set_page_status.asp?page_name=' + escape(location_object.href));
	}
	
}



//function to display shop deactivated popup
function shopClosedPopup() {

		var pop_width = 460;
		var pop_height = 560;
		window.open('suspended/index.html','ShopClosedPopup','width='+pop_width+',height='+pop_height+',scrollbars=no,resizable=no' + getWinXY (pop_width,pop_height));

}
