
//*===================================================================================

var _timeWaitMsgBoxClose = 1800;
if (document.images)
{
  preload_image = new Image(25,25); 
  preload_image.src="basketImages/saved.gif"; 
}

/*===============================================*/

function validateCNumber(obj){
	var valueSet = obj.value
	if(isNaN(valueSet)){
		obj.value = 0;
	} 
}

function myMsgBoxSaved(){
	//This is in the shoppingCart.taf and sets the default language
	var lang = document.getElementById("lang").value
	
	myMsgBoxWrapper(eval('"<table border=0><tr><td><a href=javaScript:closemyMsgBox();><img src=basketImages/'+lang+'saved.gif border=0></a></td></tr></table>"'));
	var t = setTimeout("closemyMsgBox()",_timeWaitMsgBoxClose);
}
/*======================================= myMsgBox =============================================================*/

function myMsgBoxConfirm(htmlContent,jsScript){
//<a href="javascript:myMsgBoxConfirm('html content here','alert(\'eeee\');aaa(3)')">click to confirm</a>
var htmlMsgBox = '' + 
'<table border=\"0\" width=\"375\" cellspacing=\"0\" bgcolor=\"#ffffff\" style=\"border: 1px solid #808080\"><tr><td height=\"18\" align=\"right\" style=\"padding:4px\"><A HREF=\"javaScript:closemyMsgBox()\"><img src=\"images/Skin_AccCloseBoxBut.gif\" border=\"0\"></A></td></tr><tr><td val ign=\"top\" align=\"center\" height=\"100\"><@CONTENT@><br><br><A HREF="javaScript:<@JAVASCRIPT@>">OK</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"javaScript:closemyMsgBox()\">Cancel</A></td></tr><tr><td height=\"18\" style=\"background-image: url(\'images/Skin_AccBoxBotBkg.gif\'); background-repeat: repeat-x\"><img src=\"images/Skin_AccBoxBotBkg.gif\" border=\"0\"></td></tr></table>';
	htmlMsgBox = htmlMsgBox.replace('<@CONTENT@>',htmlContent);
	htmlMsgBox = htmlMsgBox.replace('<@JAVASCRIPT@>','closemyMsgBox();' + jsScript);
	myMsgBoxWrapper(htmlMsgBox);
}

function myMsgBoxYesNo(htmlContent,jsScriptYes,jsScriptNo){
//<a href="javascript:myMsgBoxConfirm('html content here','alert(\'eeee\');aaa(3)')">click to confirm</a>
var htmlMsgBox = '' + 
'<table border=\"0\" width=\"375\" cellspacing=\"0\" bgcolor=\"#ffffff\" style=\"border: 1px solid #808080\"><tr><td height=\"18\" align=\"right\" style=\"padding:4px\"><A HREF=\"javaScript:closemyMsgBox()\"><img src=\"images/Skin_AccCloseBoxBut.gif\" border=\"0\"></A></td></tr><tr><td val ign=\"top\" align=\"center\" height=\"100\"><@CONTENT@><br><br><A HREF="javaScript:<@JAVASCRIPT_YES@>">Yes</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF=\"javaScript:<@JAVASCRIPT_NO@>\">No</A>&nbsp;&nbsp;&nbsp;<A HREF=\"javaScript:closemyMsgBox()\">Cancel</a></td></tr><tr><td height=\"18\" style=\"background-image: url(\'images/Skin_AccBoxBotBkg.gif\'); background-repeat: repeat-x\"><img src=\"images/Skin_AccBoxBotBkg.gif\" border=\"0\"></td></tr></table>';
	htmlMsgBox = htmlMsgBox.replace('<@CONTENT@>',htmlContent);
	htmlMsgBox = htmlMsgBox.replace('<@JAVASCRIPT_YES@>','closemyMsgBox();' + jsScriptYes);
	htmlMsgBox = htmlMsgBox.replace('<@JAVASCRIPT_NO@>','closemyMsgBox();' + jsScriptNo);
	myMsgBoxWrapper(htmlMsgBox);
}

function myMsgBox(htmlContent,isAutoClose){
var htmlMsgBox = '' + 
'<table border=\"0\" width=\"375\" cellspacing=\"0\" bgcolor=\"#ffffff\" style=\"border: 1px solid #808080\"><tr><td height=\"18\" align=\"right\" style=\"padding:4px\"><A HREF=\"javaScript:closemyMsgBox()\"><img src=\"images/Skin_AccCloseBoxBut.gif\" border=\"0\"></A></td></tr><tr><td val ign=\"top\" align=\"center\" height=\"100\"><@CONTENT@><br><br></td></tr><tr><td height=\"18\" style=\"background-image: url(\'images/Skin_AccBoxBotBkg.gif\'); background-repeat: repeat-x\"><img src=\"images/Skin_AccBoxBotBkg.gif\" border=\"0\"></td></tr></table>';
	htmlMsgBox = htmlMsgBox.replace('<@CONTENT@>',htmlContent);
	myMsgBoxWrapper(htmlMsgBox);
	if(isAutoClose){
	 	var t = setTimeout("closemyMsgBox()",_timeWaitMsgBoxClose);
	}
}

function myMsgBoxWrapper(htmlContent){
	document.getElementById("msgbox").innerHTML = htmlContent

	document.getElementById("msgbox").style.visibility = "visible";
	document.getElementById("msgbox").style.display = "";




	var newDivWidth = document.getElementById("msgbox").offsetWidth/2
	var newDivHeight = document.getElementById("msgbox").offsetHeight/2

	//In basket
	if(document.getElementById("phoneConfig") && document.getElementById("phoneConfig").style.visibility == 'visible'){
		var tmpConfigWidth = document.getElementById("phoneConfig").offsetLeft  + (document.getElementById("phoneConfig").offsetWidth/2 - newDivWidth)
		var tmpConfigHeight = document.getElementById("phoneConfig").offsetTop+ (document.getElementById("phoneConfig").offsetHeight/2 - newDivHeight)
	}else{
	//In shopping cart
		var tmpConfigWidth = document.body.clientWidth/2  - newDivWidth
		var tmpConfigHeight = document.body.clientHeight/2 - newDivHeight
	}
	

	document.getElementById("msgbox").style.left = tmpConfigWidth+'px';
	document.getElementById("msgbox").style.top = tmpConfigHeight+'px';

/* //OLD SCRIPT
	var divName = "msgbox";

  	if (document.getElementById){
		if (window.innerWidth || window.opera){
			pageX=window.pageXOffset;
			pageW=window.innerWidth-40;
			pageY=window.pageYOffset;
			pageH=window.innerHeight-20;
		}
		else if (document.body){
			pageX=mIecompattest().scrollLeft;
			pageW=mIecompattest().offsetWidth-40;
			pageY=mIecompattest().scrollTop;
			pageH=mIecompattest().offsetHeight-20;
		} 
	}	
	
	var responseMessageDiv = document.getElementById(divName);
	responseMessageDiv.innerHTML = htmlContent;
	responseMessageDiv.style.visibility = 'visible';
	responseMessageDiv.style.display = '';
	
	var msgboxBkg = document.getElementById("msgboxBkg");
	msgboxBkg.style.visibility = 'visible';
	msgboxBkg.style.display = '';	
	
	var myWidth = screen.width - responseMessageDiv.offsetWidth;
	myWidth = myWidth / 2;
	var myHeight = screen.height;
	myHeight = myHeight / 2 - ((myHeight / 2)/2) + pageY;

	responseMessageDiv.style.left = myWidth;
	responseMessageDiv.style.top = myHeight;

	msgboxBkg.style.left = myWidth+9;
	msgboxBkg.style.top = myHeight+9;

	//This is for the iframe
	document.getElementById("I13").style.display = '';	
	document.getElementById("I13").width = responseMessageDiv.offsetWidth - 6;
	document.getElementById("I13").height = responseMessageDiv.offsetHeight - 10;

	document.getElementById("I13").style.left = document.getElementById("msgbox").style.left
	document.getElementById("I13").style.top = document.getElementById("msgbox").style.top
	*/
}


function myMsgBoxWrapperTMP(htmlContent){

	var divName = "msgbox";


//need to fix positioning

  /*
  var newdiv = document.createElement('div');
  newdiv.setAttribute('id','aaa');
  
  var strStyle = "visibility: hidden; display:none ; z-index:500; position:absolute; padding:10;filter:progid:DXImageTransform.Microsoft.Shadow(color='gray', Direction=135, Strength=4)";
  newdiv.setAttribute('style',strStyle);
  document.body.appendChild(newdiv);

  */

	if (document.getElementById){
		if (window.innerWidth || window.opera){
			pageX=window.pageXOffset;
			pageW=window.innerWidth-40;
			pageY=window.pageYOffset;
			pageH=window.innerHeight-20;
		}
		else if (document.body){
			pageX=mIecompattest().scrollLeft;
			pageW=mIecompattest().offsetWidth-40;
			pageY=mIecompattest().scrollTop;
			pageH=mIecompattest().offsetHeight-20;
		} 
	}	

	
	var responseMessageDiv = document.getElementById(divName);
	responseMessageDiv.innerHTML = htmlContent;
	responseMessageDiv.style.visibility = 'visible';
	responseMessageDiv.style.display = '';
	
	var msgboxBkg = document.getElementById("msgboxBkg");
	msgboxBkg.style.visibility = 'visible';
	msgboxBkg.style.display = '';	
	
	//var myWidth = screen.width - responseMessageDiv.offsetWidth;
	var myWidth = document.viewport.getWidth() - responseMessageDiv.offsetWidth;
	myWidth = myWidth / 2;
	//var myHeight = screen.height;
	var myHeight = document.viewport.getHeight() 
	myHeight = myHeight / 2 - ((myHeight / 2)/2) + pageY;

	responseMessageDiv.style.left = myWidth;
	responseMessageDiv.style.top = myHeight;

	msgboxBkg.style.left = myWidth+9;
	msgboxBkg.style.top = myHeight+9;

	//This is for the iframe
	document.getElementById("I13").style.display = '';	
	document.getElementById("I13").width = responseMessageDiv.offsetWidth - 6;
	document.getElementById("I13").height = responseMessageDiv.offsetHeight - 10;

	document.getElementById("I13").style.left = document.getElementById("msgbox").style.left
	document.getElementById("I13").style.top = document.getElementById("msgbox").style.top
}




function mIecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function closemyMsgBox(){
	$("msgbox").hide()
	$('msgboxBkg').hide()
	if($("I13")) {
		document.getElementById("I13").style.display = 'none';
	}
}

/*======================================= END myMsgBox =====================================================*/




function showNotice(){
	var divName = "newNoticeBox";
   
	if (document.getElementById){
		if (window.innerWidth || window.opera){
			pageX=window.pageXOffset;
			pageW=window.innerWidth-40;
			pageY=window.pageYOffset;
			pageH=window.innerHeight-20;
		}
		else if (document.body){
			pageX=mIecompattest().scrollLeft;
			pageW=mIecompattest().offsetWidth-40;
			pageY=mIecompattest().scrollTop;
			pageH=mIecompattest().offsetHeight-20;
		} 
	}	


	var responseMessageDiv = document.getElementById(divName);
	var myWidth = screen.width - responseMessageDiv.offsetWidth;
	var myHeight = screen.height;
	
	/*
	myWidth = myWidth / 2;
	myHeight = myHeight / 2 - ((myHeight / 2)/2) + pageY;
	*/

	//THIS WILL DETERMINE THE POSITION OF THE DIV
	myWidth = (screen.width - 578) / 2; //578 is the width of the table
	myHeight = (screen.height - 266) / 2; //I am taking off 150 because of the tool bars etc

	responseMessageDiv.style.left = myWidth;
	responseMessageDiv.style.top = myHeight;

	msgboxBkg.style.left = myWidth+9;
	msgboxBkg.style.top = myHeight+9;

	responseMessageDiv.style.visibility = 'visible';
	responseMessageDiv.style.display = '';
		
}

function closeNotice(){
	var divName = "newNoticeBox";
	var responseMessageDiv = document.getElementById(divName);
	responseMessageDiv.style.visibility = 'hidden';
	responseMessageDiv.style.display = 'none';
}

function noticeRedirect(url){
	window.location = url;
}


