function productaddcart(ActionType,product_id)
{
	document.prod3.action="addtocart.php";
	document.prod3.ActionType.value=ActionType;
	document.prod3.product_id.value=product_id;
	document.prod3.submit();
}
function addtowishlist(ActionType,productid)
{
	//alert(productid);
	 window.location = "mywishlist.php?productid="+productid;
	
}
function addtocart(ActionType,productid,selected_offer_id,price,qty)
{
	document.prod3.action="addtocart.php";
	document.prod3.ActionType.value=ActionType;
	document.prod3.productid.value=productid;
	document.prod3.selected_offer_id.value=selected_offer_id;
    document.prod3.qty.value=qty;
	document.prod3.price.value=price;
	document.prod3.submit();
}

function validate(ActionType,productid,selected_renewal_offer_id,price)
{
	if(!document.prod3.txtsubID.value)
	{
		alert("Please enter subscription ID");
	}
	else
	{
		document.prod3.action="addtocart.php";
		document.prod3.ActionType.value=ActionType;
		document.prod3.productid.value=productid;
		document.prod3.selected_renewal_offer_id.value=selected_renewal_offer_id;
		document.prod3.price.value=price;
		document.prod3.submit();
	}
}

function validateoffer(doc)
{

if(eval('document.'+doc.name+'.selected_offer_id'))
{
	//alert(eval('document.'+doc.name+'.selected_offer_id'));

	//alert(document.form1.selected_offer_id1.value);
	length1=eval('document.'+doc.name+'.selected_offer_id.length');
	if (!length1)
	{
		//alert("in");
		radioselected=eval('document.'+doc.name+'.selected_offer_id.checked');
	}
	else
	{


	var radioselected = 0;
		for(var i = 0; i < length1; i++) {
			if(eval('document.'+doc.name+'.selected_offer_id[i].checked')) {
			 radioselected=eval('document.'+doc.name+'.selected_offer_id['+i+'].value');		 
			 //alert(radioselected);
			}
		}
	}
msg="";
productid = eval('document.'+doc.name+'.productid.value');
renewval = eval('document.'+doc.name+'.renewval.value');
if (renewval=="2" && document.getElementById('subscription_id').value.length =="0")
{
		msg = msg+ "Please Enter Subscription Id. \n";
		//return false;
}//renewval=="2"
	//alert(radioselected);
	if (radioselected == 0)
	{
		//alert("Please select Offer");
		msg = msg+ "Please select Offer. \n";
		//return false;
	}
	if (msg!="")
	{
		alert(msg);
		return false;
	}
}
else
{
	//alert("no");
}

//alert(renewval);
//var sublen = document.getElementById('subscription_id').value.length

//
//alert(renewval);
return true;
}

var tmpform = {close: function (dialog) {
	//alert("close");
	//$('#subscription').fadeOut();
		//$('#subscription').html('Goodbye...');
		//$('#subscription form').fadeOut(200);
		$('#subscription form').animate({
			height: 100
		}, function () {
			dialog.data.fadeOut(200, function () {
				dialog.container.fadeOut(200, function () {
					dialog.overlay.fadeOut(200, function () {
						$.modal.close();
					});
				});
			});
		});
	}}

function submit_option(deleteId)
{
	if( deleteId!=null )
	{
		document.frmcart.action="addtocart.php";
		document.frmcart.ActionType.value= "DeleteCart";
		document.frmcart.deleteId.value= deleteId;
		document.frmcart.submit(); 					

	}	// if( deleteId!=null )

}	// function submit_option(deleteId)


function SubmitPurchase(formnm,ActionType,subscription_id)
{
	//alert(subscription_id);
	// Apply Change on 06.Feb.2009 By Wasim -- for DeleteCart
	if( ActionType!=null )
	{
		// ActionType="Addtocart", "UpdateCart"
		document.frmcart.action="addtocart.php";
		document.frmcart.ActionType.value= ActionType;
		document.frmcart.subscription_id.value=subscription_id;
		document.frmcart.submit(); 

	} // if( ActionType!=null )

}	// function SubmitPurchase(formnm,ActionType)



function fetchmodel(productid)
{
	document.prod3.method="post";
	document.prod3.target="iFrame";
	document.prod3.productid.value=productid;
	document.prod3.action = "fillcombo.php?productid="+productid;
	document.prod3.submit();

}
function fetchproduct(productid)
{
	//alert(selected_offer_id);
	//document.all.showdiv.style.visibility = 'visible'; 
	offer_id = document.getElementById("offer_id").value;
	//alert(offer_id);
	subscription_type_id= document.getElementById("subscription_type_id").value;
	alert(subscription_type_id)
	document.getElementById("selected_offer_id").value=offer_id;
	url="productdetails.php?id="+document.prod3.productid.value+"&selected_offer_id="+ document.getElementById("selected_offer_id").value
	+"&subscription_type_id="+ document.getElementById("subscription_type_id").value;
	location.href=url;
	//document.prod3.action = "test.php";       
	//document.prod3.submit();   
	/*alert(product_id);
	document.all.showdiv.style.visibility = 'visible'; 
	offer_id = document.getElementById("offer_id").value;
	document.getElementById("selected_offer_id").value=offer_id;
	document.prod3.submit();*/
	
}
function fetchrenewproduct(productid)
{
	offer_id = document.getElementById("renew_offer_id").value;
	//subscription_type_id= document.getElementById("subscription_type_id").value;
	document.getElementById("selected_renewal_offer_id").value=offer_id;
	url="productdetails.php?id="+document.prod3.productid.value+"&selected_renewal_offer_id="+ document.getElementById("selected_renewal_offer_id").value;
	location.href=url;
}

function submitform(year, international,gift,offer)
	{
		cnt=0;		
	
		if(international == "0")
		{
			/*if ((gift != "") && (offer != ""))
			{			
				for (var i=0;i < document.prod3.elements.length;i++)
				{
					if (document.prod3.elements[i].type== "radio")
					{
						if(document.prod3.elements[i].checked == true)
						{								
							if(document.prod3.elements[i].name != "offer"+year)
							{								
								alert("Please choose the offer");
								return false
							}
							//return false
						}
						//alert(offernm);
						
						//document.prod3.elements[i].disabled=true
						if(document.prod3.elements[i].checked == true)
						{
							cnt++;
						}
					//}
					}
				}
			
				if(cnt == 0)
				{
					alert("You clicked the \"Subscribe Now\" button without choosing the special incentive related to it.\n\nThe special incentives are listed under each subscription offer. For example: Discount offer or Gift Offer.");
					return false
				}
			}*/
			document.prod3.countrytype.value="n";
			//document.getElementById("countrytype").value="n";
		}
		else
		{
			document.prod3.countrytype.value="i";
			//document.getElementById("countrytype").value="i";
		}
		document.prod3.offerselected.value=year;
		//Offerid -- added on 260208
		document.prod3.offerid.value=offer;
		
		document.prod3.method="post";
		document.prod3.target="_parent";
		document.prod3.Actiontype="Addtocart";
		document.prod3.action = "addtocart.php";
		document.prod3.submit();
}

function openpopup1()
{
	
	test= document.prod3.period_id.value;	
	alert(test);
	//test1=substr(test,0,1);	
	var the_length=test.length
	var last_char=test.charAt(the_length-1);
   alert('The last character is '+last_char+'.');




	if(last_char != '')
	{
		window.open('productrenewval.php?id=<?php echo $id; ?>', 'AD', 'width=710, height=150,status=no,toolbar=no,menubar=no,resizable=1,scrollbars=1');
	}
}

function getoffer(producid,type)
{
	$.POST('jquery_productdetail.php',{producid:producid,type:type,getoffer:'yes'},function (data){

	});
}


