﻿var brochures = {
    '200': '<%= base.ParentPage.BaseUrl %>products/assureon/library/Assureon_100808.pdf',
    '201': '<%= base.ParentPage.BaseUrl %>products/databeast/library/DATABeast.pdf',
    //    '202': '<%= base.ParentPage.BaseUrl %>products/dedupesg/library/DeDupeSG_Datasheet.pdf',
    '203': '<%= base.ParentPage.BaseUrl %>productsedge/library/the_edge_data_sheet.pdf',
    '204': '<%= base.ParentPage.BaseUrl %>products/nexsan_iseries/library/Nexsan_iSeries_Datasheet.pdf',
    '205': '<%= base.ParentPage.BaseUrl %>products/sasbeast/library/SASBeast_Data_Sheet.pdf',
    '206': '<%= base.ParentPage.BaseUrl %>products/sasboy/library/SASBoy_Data_Sheet.pdf',
    '207': '<%= base.ParentPage.BaseUrl %>products/satabeast/library/satabeast.pdf',
    '208': '<%= base.ParentPage.BaseUrl %>products/satabeastxi/pdf/library/SATABeastXi_0108.pdf',
    '209': '<%= base.ParentPage.BaseUrl %>products/sataboy/library/sataboy.pdf'
};

function urlParam(name)
{
	var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(location.href);
	if (!results) { return ""; }
	return results[1] || "";
}

$(document).ready(function(){
 //Get & Set URL Query String var for short form
 var campaign = urlParam("campaign");
 var source = urlParam("source");
 var source_email = urlParam("source_email");
 var source_info = urlParam("source_info");
 var source_type = urlParam("source_type");
 var source_reseller = urlParam("source_reseller");
 var docid = urlParam("docid");
 var retURL = urlParam("retURL1");
 var newWin;
 function urlParam(name)
{
	var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(location.href);
	if (!results) { return ""; }
	return results[1] || "";
}

 $(".open_gate").click(function(){
	var docid = $(this).attr("rel");
	var asset_type = (docid.substr(0,1) == "2") ? "Case_Study" : "White_Paper";
	newWin = window.open();
    $.getScript('http://now.eloqua.com/visitor/v200/svrGP.aspx?pps=50&siteid=1220&DLKey=5af807b4cb3c420ab3858d69d87b685a&DLLookup=&ms=2', function(){
		if (typeof GetElqContentPersonalizationValue == "function"){
			if(GetElqContentPersonalizationValue('V_ElqEmailAddress') != "")
			{
				var email1 = GetElqContentPersonalizationValue('V_ElqEmailAddress');
				$.getScript('http://now.eloqua.com/visitor/v200/svrGP.aspx?pps=50&siteid=1220&DLKey=7e75457646c54bb89570436652167d0e&DLLookup=%3CC_EmailAddress%3E'+email1+'%3C/C_EmailAddress%3E%3CC_SYSTEM___Gated_Form_Submitted1%3E1%3C/C_SYSTEM___Gated_Form_Submitted1%3E&ms=2', function() {
					if (typeof GetElqContentPersonalizationValue == "function") {
						if(docid.substr(0,1) == "2" && brochures[docid] != "" && brochures[docid] != "undefined")
						{
							if(GetElqContentPersonalizationValue('C_SYSTEM___Case_Study_Counter1') == 3)
							{
								newWin.location = "http://forms.nexsan.com/forms/GatedForm_CS?docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&AssetType="+asset_type;
							}
							else
							{
								newWin.location = "http://now.eloqua.com/e/f2.aspx?elqFormName=SYSTEM-ShortGatedForm&elqSiteID=1220&Email1="+email1+"&docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&retURL="+retURL+"&AssetType="+asset_type;
							}
						}
						else if(GetElqContentPersonalizationValue('C_SYSTEM___Gated_Form_Submitted1') > 0)
						{
							if(GetElqContentPersonalizationValue('C_SYSTEM___White_Paper_Counter1') == 3)
							{
								newWin.location = "http://forms.nexsan.com/forms/GatedForm_WP_v2?docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&AssetType="+asset_type;
							}
							else
							{
								//auto submit short form
								newWin.location = "http://now.eloqua.com/e/f2.aspx?elqFormName=SYSTEM-ShortGatedForm&elqSiteID=1220&Email1="+email1+"&docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&retURL="+retURL+"&AssetType="+asset_type;
							}
						}
						else
						{
							newWin.location = "http://forms.nexsan.com/forms/SYSTEM-GatedFormLP-v2?docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&AssetType="+asset_type;
						}
					}
					else
					{
						if(docid.substr(0,1) == "2" && brochures[docid] != "" && brochures[docid] != "undefined")
						{
							newWin.location = "http://now.eloqua.com/e/f2.aspx?elqFormName=SYSTEM-ShortGatedForm&elqSiteID=1220&Email1="+email1+"&docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&retURL="+retURL+"&AssetType="+asset_type;
						}
						else
						{
							newWin.location = "http://forms.nexsan.com/forms/SYSTEM-GatedFormLP-v2?docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&AssetType="+asset_type;
						}
					}
				});
			}
			else
			{
				if(docid.substr(0,1) == "2" && brochures[docid] != "" && brochures[docid] != "undefined")
				{
					newWin.location = brochures[docid];
				}
				else
				{
					newWin.location = "http://forms.nexsan.com/forms/SYSTEM-GatedFormLP-v2?docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&AssetType="+asset_type;
				}
			}
		}
		else
		{
			if(docid.substr(0,1) == "2" && brochures[docid] != "" && brochures[docid] != "undefined")
			{
					newWin.location = brochures[docid];
			}
			else
			{
				newWin.location = "http://forms.nexsan.com/forms/SYSTEM-GatedFormLP-v2?docid="+docid+"&campaign="+campaign+"&source="+source+"&source_info="+source_info+"&source_type="+source_type+"&source_email="+source_email+"&source_reseller="+source_reseller+"&AssetType="+asset_type;
			}
		}
	});
	 return false;
 });

});
