// JavaScript Document
function GetDirections()	{
	var SourceAdress = 'saddr=';
	var DestinationAddress = 'daddr=12311 Shoemaker Avenue, Santa Fe Springs, CA 90670'; //hardcoded value for the destination address			
	var Url = '';			//read out source adress from the input field
	SourceAdress += document.f_Directions.saddr.value;				//form the url 
	Url = 'http://maps.google.com/maps?' + SourceAdress + '&' + DestinationAddress; // + '&output=html';	
	
	//open url in iframe
	//frames['mapframe'].location.href = Url;						//you can use the line below to show the directions in a popup window, don;t forget to comment out the line above... 
	window.open(Url,'directions','width=980,height=760,scrollbars=yes,toolbar=no,location=no, resizable=no'); 			
}	
function docwrite(f_filename, f_width, f_height) {
	document.write('<OBJECT CLASSID="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" CODEBASE="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" WIDTH="' + f_width + '" HEIGHT="' + f_height + '" ALIGN="middle">');
	document.write('<PARAM NAME="allowScriptAccess" VALUE="sameDomain" />')
	document.write('<PARAM NAME="movie" VALUE="' + f_filename + '" /><param name="wmode" value="opaque"><PARAM NAME="quality" VALUE="high" /><PARAM NAME="bgcolor" VALUE="#ffffff" /><EMBED SRC="' + f_filename + '" QUALITY="high" BGCOLOR="#ffffff" WIDTH="' + f_width + '" HEIGHT="' + f_height + '" ALIGN="middle" allowScriptAccess="sameDomain" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"  wmode="opaque" />');
	document.write('</OBJECT>');
}

function Show(SID,Duration,Items) {
			j=Items; //# of items
			for (i=1;i<=j;i++) {
				if (document.getElementById('S'+i).style.display!='none') {
					new Effect.SlideUp(document.getElementById('S'+i),{duration:Duration});
				}
			}
			if (document.getElementById(SID).style.display=='none') {
				new Effect.SlideDown(document.getElementById(SID),{duration:Duration});
			}
	}
function Highlight(Item,Class,ClassHighlight,Items) {
			j=Items; //# of items
			for (i=1;i<=j;i++) {
					document.getElementById('Item_'+i).className=Class;
			}
			if (document.getElementById('S'+Item).style.display=='none') {
				document.getElementById('Item_'+Item).className=ClassHighlight;
			}
	}

function xmlhttpPost(strURL,strPage) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,strPage);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
    var form     = document.forms['Form'];
    var c_Category = form.c_Category.value;
    var c_Model_Number = form.c_Model_Number.value;
    var c_1 = form.c_1.value;
    var c_2 = form.c_2.value;
    var c_3 = form.c_3.value;
    var c_4 = form.c_4.value;
    var c_5 = form.c_5.value;
    var c_6 = form.c_6.value;
    var c_7 = form.c_7.value;
    var c_8 = form.c_8.value;
    var c_12 = form.c_12.value;
    var f_Section_Name=form.f_Section_Name.value;
    
    qstr = 'c_Category=' + escape(c_Category) + '&f_Section_Name=' + escape(f_Section_Name) + '&c_Model_Number=' + escape(c_Model_Number) + '&c_1=' + escape(c_1) + '&c_2=' + escape(c_2) + '&c_3=' + escape(c_3) + '&c_4=' + escape(c_4) + '&c_5=' + escape(c_5) + '&c_6=' + escape(c_6) + '&c_7=' + escape(c_7) + '&c_8=' + escape(c_8) + '&c_12=' + escape(c_12);  // NOTE: no '?' before querystring
   return qstr;
}

function xmlhttpPostCategory(strURL,strPage) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,strPage);
        }
    }
    self.xmlHttpReq.send(getquerystringCategory());
}

function getquerystringCategory() { 
    qstr = '?CatID=<%=Request("CatID")%>';  // NOTE: no '?' before querystring
    return qstr;
}

function xmlhttpPostDownload(strURL,strPage) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,strPage);
        }
    }
    self.xmlHttpReq.send(getquerystringDownload());
}
function getquerystringDownload() { 
    var form     = document.forms['Form1'];
    var c_Type = form.c_Type.value;
    var c_URL_Temp = form.c_URL_Temp.value;
    
    qstr = 'c_Type=' + escape(c_Type) + '&c_URL_Temp=' + escape(c_URL_Temp);  // NOTE: no '?' before querystring
    return qstr;
}


function xmlhttpPostUsers(strURL,strPage) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,strPage);
        }
    }
    self.xmlHttpReq.send(getquerystringUsers());
}

function getquerystringUsers() { 
    var form     = document.forms['Form'];
    var c_Search = form.c_Search.value;
    
    qstr = 'c_Search=' + escape(c_Search);  // NOTE: no '?' before querystring
    return qstr;
}


function updatepage(str,strPage){
    document.getElementById(strPage).innerHTML = str;
}


function fn_Sort(f_ID,f_URL)
{
	Sortable.create(f_ID,
	{
	    onUpdate: function()
	    {
		   new Ajax.Request(f_URL,
		   {
			  method: "post",
			  parameters: { data: Sortable.serialize(f_ID) }
		   }
		   );
	    } 
	}
	);
}




function xmlhttpPostTopSearch(strURL,strPage) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,strPage);
        }
    }
    self.xmlHttpReq.send(getquerystringTopSearch());
}

function getquerystringTopSearch() {
    var form     = document.forms['f_Top_Search'];
    var frm_Search = form.frm_Search.value;
    qstr = 'c_Search=' + escape(frm_Search);  // NOTE: no '?' before querystring
   return qstr;
}
