function getRequestParameter(sKey)
{
	var sQueryString = window.location.search.substring(1);
	var aQueryString = sQueryString.split("&");
	for (var iQS = 0; iQS < aQueryString.length; iQS++)
	{
		var aKeyValPair = Array();
		aKeyValPair = aQueryString[iQS].split("=");
		if (aKeyValPair[0] == sKey)
		{
			return aKeyValPair[1];
		}
	}
	return "";
}


function setRequestedPackages(iTotal)
{
	var sPackages = getRequestParameter("p");
	if(iTotal > 0) 
	{
		var aPackages         = sPackages.split(",");
		var iNumberOfPackages = aPackages.length;
		for (var iPack = 0; iPack < iNumberOfPackages; iPack++)
		{
			aPackageUnits = aPackages[iPack].split('-');
			if(aPackageUnits[1])
			{
				aPackages[iPack] = aPackageUnits[0];
			}
			iCurGroup = 0;
			for(k=1;k<=iTotal;k++)
			{
				id= 'sPackageNo' + k;
			    iCurPackageVal = eval(document.getElementById(id)).value;
			    id2 = 'hidDisplayType' + k;
			    iDisplayType = eval(document.getElementById(id2)).value;
			    if(iDisplayType == 2)
				{
					id3 = 'hidGroupId' + k;
					iGroupId = eval(document.getElementById(id3)).value;
					id3 = 'hidSize' + iGroupId;
					iSize = eval(document.getElementById(id3)).value;
					if(iSize > 1)
					{
						if(iCurGroup == iGroupId)
						{
							iIndex++;
						}
						else
						{
							iCurGroup = iGroupId;
							iIndex = 0;
						}
					}
					else
					{
						iCurGroup = iGroupId;
						iIndex = 0;
					}  
				}
				
			    if(iCurPackageVal == aPackages[iPack])
			    {
				    id2 = 'hidDisplayType' + k;
				    iDisplayType = eval(document.getElementById(id2)).value;
				    if(iDisplayType == 1)
					{
						var oChk = eval('document.getElementById(\'paypalform\').product'+iCurPackageVal);
					}
					else
					{
						id3 = 'hidGroupId' + k;
						iGroupId = eval(document.getElementById(id3)).value;
						id3 = 'hidSize' + iGroupId;
						iSize = eval(document.getElementById(id3)).value;
						if(iSize == 1)
							var oChk = eval('document.getElementById(\'paypalform\').products'+iGroupId);
						else
						 	var oChk = eval('document.getElementById(\'paypalform\').products'+iGroupId+'['+iIndex+']');
					}
				    oChk.checked = true;
				    var sSecondArg = document.getElementById('paypalform').num_links.value+','+aPackages[iPack];
				    sTxtHourName = 'txtHour' + k; 
				    if(aPackageUnits[1] && document.getElementById(sTxtHourName))
					{
						sTxtHourName = 'txtHour' + k; 
						document.getElementById(sTxtHourName).value = aPackageUnits[1];
						perHourPayment(sSecondArg,k)
					}
					else
					{
						calcHourPrice(oChk,sSecondArg);
					}
			    }
		    }
		}
	}
	
	return true;
}

function setRequestedMoreInfo(iTotal)
{
	var sMI = getRequestParameter("mi");
	if(sMI.length > 0)
	{
		var aMI         = sMI.split(",");
		var iNumberOfMI = aMI.length;
		for (var iM = 0; iM < iNumberOfMI; iM++)
		{
			for(k=1;k<=iTotal;k++)
			{
				id= 'sPackageNo' + k;
				
			    iCurPackageVal = eval(document.getElementById(id)).value;
			    if(iCurPackageVal == aMI[iM])
			    {
				    var sPostId = 'hd'+k;
					expandcollapse(sPostId);
			    }
		    }
		}
	}
	return true;
}

function setCoupon(iTotal)
{
	var sVal = getRequestParameter("v");
	if(sVal != '')
	{
		document.getElementById("voucher").value = sVal;
		validateApplyDiscount('');
		return true;
    }
    else
    {
	    return false;
    }
}