function getPricesAndProvs(pid){
}

function np_switchPic(obj,img){
	obj.src = img;
}


// **************************** FOR JAMES GOT THIS FROM BELL START ****************************************
function addPhone(pid) {
	if(checkQTY($('qty_'+pid))) {
		if($('qty_'+pid).value <= 0){
			showDialog("","",1,"Invalid quantity")
		} else {
			qty = $('qty_'+pid).value
			dType = 0
			if($('dataType_'+pid)) {
				dType = $('dataType_'+pid)[$('dataType_'+pid).selectedIndex].value
			}
			//alert('ajax/ajax_basket.taf?method=AddToCart&phoneArray='+pid+','+qty+","+dType)
			exFetch('ajax/ajax_basket.taf?method=AddToCart&phoneArray='+pid+','+qty+","+dType,'',function(){goto('shoppingCart')})
		}
	}
}

function addMultiPhone() {

	var pList = ''
	var thisPhone
	var qtyBox
	var selOK = 1 //data type section
	var selType
	//check to see if any selected phones require data category
	$('content').select('.selDataType').each(function(element) {
		qtyBox = element.id.split("_")
		if(element.selectedIndex<1&&$("qty_"+qtyBox[1]).value>0) {
			selOK = 0	
		}
	})
	if(selOK==0) {
		showDialog("","",1,"Select a card type")
		return;
	}

	$('content').select('.qtyInputLower').each(function(element) {
		//if(checkQTY(element)) {

			if(element.value>0) {
				
				thisPhone = element.id.split("_")
				//add data categoryid if present
				
				if(element.up().next()) {
					selType = element.up().next()
				
					if(selType.hasClassName('selDataType')) {
						pList = pList + thisPhone[1]+","+element.value+","+selType[selType.selectedIndex].value+";"
					}
					else {
					pList = pList + thisPhone[1]+","+element.value+",0;"
					}

				}
				else {
			
					pList = pList + thisPhone[1]+","+element.value+",0;"	
				}
			}
		//}
	})

	if(pList!='') {
		//x=prompt('','ajax/ajax_basket.taf?method=AddToCart&phoneArray='+pList)
		exFetch('ajax/ajax_basket.taf?method=AddToCart&phoneArray='+pList,'',function(){goto('shoppingCart')})
		
		
		
	}
	else {
		showDialog("","",1,"Invalid quantity")	
	}
}
// **************************** FOR JAMES GOT THIS FROM BELL END ****************************************






//NEW FUNCTION FOR PHONE LIST
function addToCart(key){
	var phoneArray = ''
	var phoneIds = ''
	var qtyEntered = 0 //This will validate if a quantity si greater than 0


	$$('qtyInputLower').each(function() {
		if(element.value!=0) {
			logThis(element.id)	
		}
	})

	for(i=1;i<=document.phoneForm.length;i++){
		if(eval('document.phoneForm.phoneQty'+i+' &&  document.phoneForm.phoneQty'+i+'.value > 0')){
			qtyEntered = 1 //This will validate if a quantity si greater than 0

			phoneArray += eval('document.phoneForm.phoneId'+i+'.value')
			phoneArray += ','
			phoneArray += eval('document.phoneForm.phoneQty'+i+'.value')
			phoneArray += ';'
			
			//Reset Quantity
			eval('document.phoneForm.phoneQty'+i+'.value = 0')
			
			phoneIds += eval('document.phoneForm.phoneId'+i+'.value')+','
		}
	}

	if(qtyEntered == 0){
		alert('In order to continue you will have to enter a quantity greater than zero!')
		return	
	}

 	//var oAjax = new myAjax();

	//Multi Carrier Order Block
	if(document.getElementById("restrictMultiCarrierPurchase").value == 1){
		phoneIds = phoneIds.substring(0, phoneIds.length - 1)

		//oAjax.Send("ajax/ajax_checkMultiCarrierOrder.taf?method=AddToCart&phoneIds=" + phoneIds + "&" + key);
		var url = "ajax/ajax_checkMultiCarrierOrder.taf?method=AddToCart&phoneIds=" + phoneIds + "&" + key
		new Ajax.Request(url, {
		  onSuccess: function(response) {
			if(response.responseText == 0){
				multiCarrierOrder()
				return
			}
			
			
			phoneArray = phoneArray.substring(0, phoneArray.length - 1) 
			//oAjax.Send("ajax/ajax_basket.taf?method=AddToCart&phoneArray=" + phoneArray + "&" + key);
			
			var url = "ajax/ajax_basket.taf?method=AddToCart&phoneArray=" + phoneArray + "&" + key
			new Ajax.Request(url, {
			  onSuccess: function(response) {
				//It needs this otherwise it does not write the phones to the database - It has to with the delay of the ajax
				myMsgBoxWrapper(oAjax.Response(),274);
				window.location.href = document.getElementById("goToURL").value;
		
			  }
			});
			
	
		  }
		});
		
		

	}


}




function addSinglePhoneToCart(pid,key){
	if(!$("qty_"+pid)) {
		var phoneQty = 1	
	}
	else {
		if($("qty_"+pid).value==0 || $("qty_"+pid).value=='') {
			var phoneQty = 1								
		}
		else {
			var phoneQty = $("qty_"+pid).value
		}
	}
	var dType = 0 
	if($('dataType_'+pid)) {
		if($('dataType_'+pid).selectedIndex<1) {
			alert("Please select a data type")
			return;
		}
		else {
			dType = $('dataType_'+pid)[$('dataType_'+pid).selectedIndex].value
		}
	}
	//if(eval('document.phoneForm.phoneQty'+whichBox+'.value') == 0 || eval('document.phoneForm.phoneQty'+whichBox+'.value') == ''){
	//	var phoneQty = 1
	//}else{
	//	var phoneQty = eval('document.phoneForm.phoneQty'+whichBox+'.value')
	//}


	var phoneArray = ''
	phoneArray += pid
	phoneArray += ','
	phoneArray += phoneQty
	phoneArray += ','
	phoneArray += dType
	phoneArray += ';'

	var url = "ajax/ajax_checkMultiCarrierOrder.taf?method=AddToCart&phoneIds=" + pid + "&_UserReference=" + key	
	new Ajax.Request(url, {
	  onSuccess: function(response) {
		//alert("response: " + response.responseText)

		if(response.text==0) {
			multiCarrierOrder()
			return
		}
		else {
			url = "ajax/ajax_basket.taf?method=AddToCart&phoneArray=" + phoneArray + "&_UserReference=" + key
			new Ajax.Request(url, {
			  onSuccess: function(response) {

				document.location = globalFilePath2  + "?_function=shoppingCart&_UserReference=" + key
			  }
			});

		}
	  }
	});

}





















function multiCarrierOrder(){
	var divContent = ""
	divContent += '<table border="1" width="350" cellspacing="0" cellpadding="0" bordercolor="#49166D" style="border-collapse: collapse">'
	divContent += '<tr>'
	divContent += '<td>'
	divContent += '<table border="0" width="100%" cellspacing="0" cellpadding="0">'
	divContent += '<tr>'
	divContent += '<td bgcolor="#76D100" class="whiteSubHeader" style="padding-left:10px;" align="left">Multi Carrier Order</td>'
	divContent += '<td bgcolor="#76D100" class="whiteSubHeader" style="padding-left:10px; padding-right:5px" height="32" align="right"><a href="javascript:closeGlobalDiv(\'msgbox\')"><img border="0" src="basketImages/redX.gif" onmouseover="this.src=\'basketImages/blueX.gif\'" onmouseout="this.src=\'basketImages/redX.gif\'"></a></td>'
	divContent += '</tr>'
	divContent += '<tr>'
	divContent += '<td colspan="2" bgcolor="#FFFFFF" style="padding:10px" align="left">'
	divContent += 'Unfortunately we cannot allow purchases of different handset types. To purchase this handset either complete your existing order or remove all other handsets.'
	divContent += '</td>'
	divContent += '</tr>'
	divContent += '</table>'
	divContent += '</td>'
	divContent += '</tr>'
	divContent += '</table>'

	document.getElementById("msgbox").style.display = "";
	document.getElementById("msgbox").style.visibility = "visible";
	document.getElementById("msgbox").innerHTML = divContent

	positionDivInsideBasket("msgbox")

	pageY=mIecompattest().scrollTop;
	document.getElementById("msgbox").style.top = pageY + 300
}
function mIecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function closeGlobalDiv(divName){
	document.getElementById("msgbox").style.display = "none";
	document.getElementById("msgbox").style.visibility = "hidden";
}










/*
function addSinglePhoneToCart(whichBox,key){
	if(eval('document.phoneForm.'+whichBox+'.value == 0')){
		eval('document.phoneForm.'+whichBox+'.value = 1')
	}

	addToCart(key)
}
*/

function resetPhoneListQty(){
	for(i=1;i<=document.phoneForm.length;i++){
		if(eval('document.phoneForm.phoneQty'+i+' &&  document.phoneForm.phoneQty'+i+'.value > 0')){
			eval('document.phoneForm.phoneQty'+i+'.value = 0')
		}
	}
}


/* THE WAY THE PRICE DIV IN THE PRODUCT LIST USED TO WORK
function getPhoneInfo(objLnk,pid,key){
	//alert(document.getElementById("accDiv").offsetWidth );
	//alert(objLnk.x);
	//return;
	var oAjax = new myAjax();
	oAjax.Send("ajax/ajax_NewPhones_GetPhoneByPID.taf?pid=" + pid + "&_UserReference=" + key);
	myMsgBoxWrapper(oAjax.Response());
}

function GoToPhoneDetails(){
	if(document.formPhoneInfoGo.provinceId.selectedIndex > 0 ) document.formPhoneInfoGo.submit()
}
*/


//THESE NEXT FUNCTIONS ARE RELATED TO THE PRODUCT PRICING DIV IN THE PRODUCT LIST
function XgetPhoneProvinceList(pid,key){
	var oAjax = new myAjax();
	oAjax.Send("ajax/ajax_NewPhones_GetPhoneByPID.taf?pid=" + pid + "&_UserReference=" + key);
	myMsgBoxWrapperTMP(oAjax.Response());
}

function getPhoneProvinceList(pid,key){
	//var oAjax = new myAjax();
	//oAjax.Send("ajax/ajax_NewPhones_GetPhoneByPID.taf?pid=" + pid + "&_UserReference=" + key);
	//myMsgBoxWrapperTMP(oAjax.Response());
	//msgbox
	var url = "ajax/ajax_NewPhones_GetPhoneByPID.taf?pid=" + pid + "&_UserReference=" + key
	new Ajax.Updater('msgbox', url,{onComplete:function(){positionMsgBox($('phone'+pid))}});
	var myPos = findPos($('phone'+pid))
	

}

function positionMsgBox(element) {
	var myPos = findPos(element)
	$('msgbox').style.top = myPos[1]+20+'px'
	$('msgbox').style.left = myPos[0]+18+'px'
	$('msgboxBkg').style.top = myPos[1]+24+'px'
	$('msgboxBkg').style.left = myPos[0]+22+'px'
	showMsgBox()
}

function showMsgBox() {
	$('msgboxBkg').style.height = $('msgbox').getHeight() + 'px'
	$('msgboxBkg').style.width = $('msgbox').getWidth() + 'px'
	$('msgboxBkg').show()
	$('msgbox').show()
}


function XtermAndPriceDetails(phoneId,provinceId,key,pName){
	if(provinceId){

		//Hide pop up
		$("msgbox").hide()
		$("msgboxBkg").hide()

		//Without this it cuts the pName up to the point of the &
		var pName = pName.replace("&","^^")

		var oAjax = new myAjax();
		oAjax.Send("ajax/ajax_getTermsAndPricingByPId_ProvId.taf?phoneId=" + phoneId + "&provinceId=" + provinceId + "&pName="+pName+"&_UserReference=" + key);

		myMsgBoxWrapperTMP(oAjax.Response());
	}
}

function termAndPriceDetails(phoneId,provinceId,key,pName){
	if(provinceId){

		//Hide pop up
		$("msgbox").hide()
		$("msgboxBkg").hide()

		//Without this it cuts the pName up to the point of the &
		var pName = pName.replace("&","^^")

		var url = "ajax/ajax_getTermsAndPricingByPId_ProvId.taf?phoneId=" + phoneId + "&provinceId=" + provinceId + "&pName="+pName+"&_UserReference=" + key

		new Ajax.Updater('msgbox', url,{onComplete:showMsgBox});

	}
}


/*


var verticalpos="fromtop";
var currentTimer;
function FloatPriceDiv(){
	//THIS WILL DETERMINE THE POSITION OF THE DIV
	var startX = (screen.width - 400) / 2;
	var startY = (screen.height - 116) / 2 - 250; //I am taking off 150 because of the tool bars etc
	
	var ns 		= (navigator.appName.indexOf("Netscape") != -1);
	var d 		= document;
	
	function ml(id){
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)
			el.style=el;
			el.sP=function(x,y){this.style.left=x;this.style.top=y;};
			el.x = startX;
			if (verticalpos=="fromtop"){
				el.y = startY;
				alert(1)
			}else{
				el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
				el.y -= startY;
				alert(2)
			}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
			var pY = ns ? pageYOffset : document.body.scrollTop;
			ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
			var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
			ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		
		ftlObj.sP(ftlObj.x, ftlObj.y);
		currentTimer = setTimeout("stayTopLeft()", 10);
	}

	ftlObj = ml('phoneTermPricing');
	stayTopLeft();
}

*/

