function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        xmlHttp=new XMLHttpRequest();
    }
    catch(e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}



function checkemail(str)
{
    var testresults;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

    if (filter.test(str))
        testresults=true
    else
        testresults=false

    return (testresults)
}

function CalculateTop(Height)
{
    var ScrollTop=document.body.scrollTop;
    if(ScrollTop==0)
    {
        if(window.pageYOffset)
            ScrollTop=window.pageYOffset;
        else
            ScrollTop=(document.body.parentElement)?document.body.parentElement.scrollTop:0;
    }

    var BodyHeight=document.body.clientHeight;

    if(BodyHeight==0)
    {
        BodyHeight=window.innerHeight;
    }
    if(BodyHeight==0)
    {
        BodyHeight=document.documentElement.clientHeight
    }

    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' )
    {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }

    var FinalTop=((myHeight-Height)/2)+ScrollTop;

    return FinalTop;
}

function CalculateLeft(Weight)
{
    var ScrollLeft=document.body.scrollLeft;

    if(ScrollLeft==0)
    {
        if(window.pageXOffset)
            ScrollLeft=window.pageXOffset;
        else
            ScrollLeft=(document.body.parentElement)?document.body.parentElement.scrollLeft:0;
    }

    var BodyWeight=document.documentElement.clientWidth;

    if(BodyWeight==0)
    {
        BodyWeight=document.body.clientWidth;
    }

    var FinalLeft=(BodyWeight+ScrollLeft-Weight)/2;

    return FinalLeft;
}
/*********** Ajax Loader New *************/
function ProcessLoader()
{
    document.getElementById('dvprocessing').style.display = '';
//alert("top- first"+document.getElementById('loadertext').style.top);
//alert("left- first"+document.getElementById('loadertext').style.left);
	
//--------
/*document.getElementById('dvprocessing').style.display = '';
	document.getElementById('dvprocessing').style.width = '';
    document.getElementById('dvprocessing').style.height = '';
	document.getElementById('dvprocessing').style.top = CalculateTop('32')+ "px";
    document.getElementById('dvprocessing').style.left = CalculateLeft('32')-60+ "px";
    document.getElementById('dvprocessing').style.backgroundColor = 'white';*/
//-------
	
/*posY = getScreenCenterY(); alert(posY);
	posX = getScreenCenterX();alert(posX);
	
	document.getElementById('dvprocessing').style.top = posY+ "px";
    document.getElementById('dvprocessing').style.left = posX+ "px";*/
	
//alert(CalculateLeft('32')-20);
}
/****************************************/

/***************** Setting the Dimmer while loading *********************/
function SetBackground()
{
	
    if(ie)
    {
        FinalHeight=document.body.clientHeight;
        FinalHeight=FinalHeight-85;
        FinalHeight=FinalHeight+ "px";
        document.getElementById('dimmer').style.height=FinalHeight;
    }
    else
    {
        document.getElementById('dimmer').style.height=GetBodyHeight();
    }
	
    document.getElementById('dimmer').style.width=GetBodyWidth();
    document.getElementById('dimmer').style.visibility="visible";
	
}
function UnsetBackground()
{
    document.getElementById('dimmer').style.width=0;
    document.getElementById('dimmer').style.height=0;
    document.getElementById('dimmer').style.visibility="";
    document.getElementById('dvprocessing').style.display = 'none';
	
    unhideIframe();
}
function unhideIframe()
{
    if(ie)
    {
        var theIframe=document.getElementById("fadeboxiframe");
        var theDiv=document.getElementById("dvregisterfrm");
    //theIframe.style.width=theDiv.offsetWidth+'px';alert("ok1");
    //theIframe.style.height=theDiv.offsetHeight+'px';alert("ok2");
    //theIframe.style.top=theDiv.offsetTop+'px';alert("ok3");
    //theIframe.style.left=theDiv.offsetLeft+'px';alert("ok4");
    //theIframe.style.display='';alert("ok7");
    }
}
/***********************************************************************/
function init()
{
    isMozilla=(document.all)?0:1;
    if(isMozilla)
    {
        document.captureEvents(Event.MOUSEDOWN|Event.MOUSEMOVE|Event.MOUSEUP);
    }
}

init();

function GetBodyWidth()
{
    var theWidth=0;
    if(document.body)
    {
        theWidth=document.body.clientWidth;
    }
    else if(document.documentElement&&document.documentElement.clientWidth)
    {
        theWidth=document.documentElement.clientWidth;
    }
    else if(window.innerWidth)
    {
        theWidth=window.innerWidth;
    }

    theWidth=theWidth-85;

    return theWidth+ "px";
}

function GetBodyHeight()
{
    //alert("in hedight");
    var theHeight1=0;
    var theHeight2=0;
    var theHeight3=0;
    if(window.innerHeight)
    {
        theHeight1=window.innerHeight;
    }
    if(document.documentElement&&document.documentElement.clientHeight)
    {
        theHeight2=document.documentElement.clientHeight;
    }
    if(document.body)
    {
        theHeight3=document.body.clientHeight;
        if(isMozilla)
        {
            theHeight4=0;
        }
        else
        {
            heHeight4=document.body.scrollHeight;
        }
    }

    FinalHeight=Math.max(theHeight1,theHeight2,theHeight3,theHeight4);
    FinalHeight=FinalHeight-85;
    return FinalHeight+ "px";
}
/******************************************************************************/
/**** function to fetch url query param ******/
function gup( name )
{
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
        return "";
    else
        return results[1];
}
/*********************************************/

/******** Only Numeric **********/
function onlyNumeric(evt)
{
    var charCode = (evt.which) ? evt.which : event.keyCode;
    //alert(charCode);
	
    if(charCode == 46)
    {
        return true;
    }
    else if (charCode > 96 && charCode < 123)
    {
        return false;
    }
    else if(charCode > 47 && charCode < 58)
    {
        return true;
    }
    else
    {
        return false;
    }
}

function KeycheckOnlyPhonenumber(e)
{
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    //alert(_dom);
    if(_dom==2){                     // for NN4
        //alert(e.which);
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            //alert('Mozilla:' + e.charCode);
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }

    if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 39) || (KeyID >= 42 && KeyID <= 44) || (KeyID >= 46 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        //alert("hello");
        return false;
    }
	
    return true;
}

function limitlength(obj, length)
{
    var maxlength=length
    if (obj.value.length>maxlength)
        obj.value=obj.value.substring(0, maxlength)
}

/********************************/

/**** Check all checkboxes for delete *****/
function checkall(parentid, childid)
{	
    if(document.getElementById(parentid).checked == true)
    {
        var chkelements = document.getElementsByName(childid);
		
        for(var i = 0; i < chkelements.length; i++)
        {
            chkelements.item(i).checked = true;
        }
    }
    else
    {
        var chkelements = document.getElementsByName(childid);
		
        for(var i = 0; i < chkelements.length; i++)
        {
            chkelements.item(i).checked = false;
        }
    }
}
/******************************************/

/***** Delete rows *******/
function deleteRows(page, pagesize, pagenumber, orderfield, ordertype, srhtxt)
{
    var chkelements = document.getElementsByName('chk');
    var ids = "";
    var countChecked = 0;
	
    var chksubelements = document.getElementsByName('chksub');
    var subids = "";
    var subCountChecked = 0;
	
    for(var j = 0; j < chksubelements.length; j++)
    {
        if(chksubelements.item(j).checked)
        {
            subCountChecked++;
			
            if(subids != "")
                subids += ",";
            subids += chksubelements.item(j).value;
        }
    }
	
    for(var i = 0; i < chkelements.length; i++)
    {
        if(chkelements.item(i).checked)
        {
            countChecked++;
			
            if(ids != "")
                ids += ",";
            ids += chkelements.item(i).value;
        }
    }
	
    if(countChecked == 0 && subCountChecked == 0)
    {
        alert("Please select atleast one record for delete");
        return;
    }
	
    var answer = confirm("Do you really want to delete?");
    if(!answer)
    {
        return;
    }
    //alert(ids);
    if(countChecked != 0 && subCountChecked == 0)
    {
        //alert("normal : " + ids);
        sendPagingRequest(page, "?action=delete&paging=yes&ids=" + ids + "&pagesize=" + pagesize + "&pagenumber=" + pagenumber + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
    }
    else if(countChecked == 0 && subCountChecked != 0)
    {
        //alert("sub : " + subids);
        sendPagingRequest(page, "?action=deletesub&paging=yes&subids=" + subids + "&subids=" + subids + "&pagesize=" + pagesize + "&pagenumber=" + pagenumber + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
    }
    else if(countChecked != 0 && subCountChecked != 0)
    {
        //alert("normal : " + ids + " sub : " + subids);
        sendPagingRequest(page, "?action=deleteall&paging=yes&ids=" + ids + "&subids=" + subids + "&pagesize=" + pagesize + "&pagenumber=" + pagenumber + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
    }
}

function deleteRows1(page, pagesize, pagenumber, orderfield, ordertype, srhtxt,action)
{
    var chkelements = document.getElementsByName('chk');
    var ids = "";
    var countChecked = 0;
    var trash_type=document.getElementById('fk_manuglcode').value;
    var chksubelements = document.getElementsByName('chksub');
    var subids = "";
    var subCountChecked = 0;
	
    for(var j = 0; j < chksubelements.length; j++)
    {
        if(chksubelements.item(j).checked)
        {
            subCountChecked++;
			
            if(subids != "")
                subids += ",";
            subids += chksubelements.item(j).value;
        }
    }
	
    for(var i = 0; i < chkelements.length; i++)
    {
        if(chkelements.item(i).checked)
        {
            countChecked++;
			
            if(ids != "")
                ids += ",";
            ids += chkelements.item(i).value;
        }
    }
	
    if(countChecked == 0 && subCountChecked == 0)
    {
        alert("Please select atleast one row for "+action);
        return;
    }
	
    var answer = confirm("Do you really want to "+action+"?");
    if(!answer)
    {
        return;
    }
    //alert(ids);
    if(countChecked != 0 && subCountChecked == 0)
    {
        //alert("normal : " + ids);
        //alert(action);
        sendPagingRequest(page, "?action="+action+"&paging=yes&ids=" + ids + "&pagesize=" + pagesize +"&trash_type="+trash_type+ "&pagenumber=" + pagenumber + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
    }
    else if(countChecked == 0 && subCountChecked != 0)
    {
        //alert("sub : " + subids);
        sendPagingRequest(page, "?action=deletesub&paging=yes&subids=" + subids + "&subids=" + subids +"&trash_type="+trash_type+ "&pagesize=" + pagesize + "&pagenumber=" + pagenumber + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
    }
    else if(countChecked != 0 && subCountChecked != 0)
    {
        //alert("normal : " + ids + " sub : " + subids);
        sendPagingRequest(page, "?action=deleteall&paging=yes&ids=" + ids + "&subids=" + subids + "&pagesize=" + pagesize + "&trash_type="+trash_type+"&pagenumber=" + pagenumber + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
    }
}
/*************************/

/********* Goto Page Directly **********/
function gotoPage(page, id, pagesize, orderfield, ordertype, srhtxt,noofpage)
{
    //alert("in");
    var pageno = document.getElementById(id).value;
    pageno=parseInt(pageno);
    noofpage=parseInt(noofpage);
    //alert(pageno>noofpage);
    //alert(pageno);
    //return false;
    if(pageno>noofpage || pageno < 1)
    {
        alert("Please enter a valid page number");
        return false;
    }
    //alert(pageno);
    //alert("?paging=yes&pagesize=" + pagesize + "&pagenumber=" + pageno + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt);
    sendPagingRequest(page, "?paging=yes&pagesize=" + pagesize + "&pagenumber=" + pageno + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
}
function gotoPage1(page, id, pagesize, orderfield, ordertype, srhtxt,noofpage)
{
	
    var pageno = document.getElementById(id).value;
    if(pageno>noofpage)
    {
        return false;
    }
    var trash_type=document.getElementById('fk_manuglcode').value;
    sendPagingRequest(page, "?paging=yes&pagesize=" + pagesize + "&pagenumber=" + pageno + "&trash_type="+trash_type+"&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
}
/***************************************/

/********* listing page size **********/
function listing(page, pagesize,srhtxt)
{
    //alert("in");
    //var srhtxt = document.getElementById('txtsearch').value;
    //alert(srhtxt);
    sendPagingRequest(page, "?paging=yes&pagesize=" + pagesize+ "&srhtxt=" + srhtxt, 'gridbody');
}
function listing_model(page, pagesize,srhtxt)
{
    //alert("in");
    //var srhtxt = document.getElementById('txtsearch').value;
    //alert(srhtxt);
    sendPagingRequest(page, "?paging=yes&pagesize=" + pagesize+ "&srhtxt=" + srhtxt, 'gridbody');
}
function listing1(page, pagesize,srhtxt)
{
    //alert("in");
    var srhtxt = document.getElementById('txtsearch').value;
    var trash_type=document.getElementById('fk_manuglcode').value;
    sendPagingRequest(page, "?paging=yes&pagesize=" + pagesize+"&trash_type="+trash_type+"&srhtxt=" + srhtxt, 'gridbody');
}
function listing_image(page, pagesize,srhtxt)
{
    //alert("in");
    var srhtxt = document.getElementById('txtsearch').value;
    //alert(srhtxt);
    sendPagingRequest(page, "&paging=yes&pagesize=" + pagesize+ "&srhtxt=" + srhtxt, 'gridbody');
}
/****************************/

function sendAddRequest(url, parameters, method, redirecturl)
{
    //alert(url + parameters);
    xmlHttp = GetXmlHttpObject();

    if(xmlHttp != null)
    {
        //alert("xmlHttp not null");
        if(method == "POST")
        {
            //alert("inside post");
            xmlHttp.onreadystatechange = function() {
                //alert("onreadystatechange");
                SetBackground(); // set dimmer
                if(xmlHttp.readyState==1)
                {
                    ProcessLoader(); // set loading text
                }
                if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
                {
                    //alert(xmlHttp.responseText);
                    var str =  xmlHttp.responseText;
					
                    if(str == 1) // Added successfully
                    {
                        location.href = redirecturl + "msg=1";
                    }
                    else if(str == 2) // Edited successfully
                    {
                        location.href = redirecturl + "msg=2";
                    }
                    else if(str == 3) // Already exists!
                    {
                        document.getElementById('errormsg').style.display = "";
                    }
                    else if(str == 4) // Edited successfully on same page
                    {
                        document.getElementById('errormsg').style.display = "";
                    }
                    else
                    {
                        alert("There seems to be some problem. Please try again later..");
                    //alert(xmlHttp.responseText);
                    }
					
                    UnsetBackground(); //Remove Loader
                }
            };
            xmlHttp.open('POST', url, true);
            xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlHttp.setRequestHeader("Content-length", parameters.length);
            xmlHttp.setRequestHeader("Connection", "close");
			
            xmlHttp.send(parameters);
        }
        else if(method == "GET")
        {
            xmlHttp.onreadystatechange = function () {
				
            };
			
            xmlHttp.open('GET', url + parameters, true);
            xmlHttp.send(null);
        }
    }
    else
    {
        alert("Your browser does not support HTTP Request");
    }
}

function sendPagingRequest(url, parameters, targetdiv)
{
    //alert(url);
    //alert(parameters);
    //alert(targetdiv);
    xmlHttp = GetXmlHttpObject();
	
    if(xmlHttp != null)
    {
		
        xmlHttp.onreadystatechange = function() {
            //alert(url+parameters);
            SetBackground(); // set dimmer
            //alert("in");
            if(xmlHttp.readyState==1)
            {
                ProcessLoader(); // set loading text
            }
			
            if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
            {
				
                var str =  xmlHttp.responseText;
                //alert(str);
                //alert(targetdiv);
                if(url=="ajax_data.php")
                {
                    document.getElementById(targetdiv).innerHTML =str;
                }
                else
                {
                    var strarray = str.split("****");
                    //alert(strarray[1]);
                    document.getElementById(targetdiv).innerHTML = strarray[1];
                }
                //listing1('trash.php', 10);
                UnsetBackground(); //Remove Loader
            }
        };

        xmlHttp.open('GET', url + parameters, true);
        xmlHttp.send(null);
    }
    else
    {
        alert("Your browser does not support HTTP Request");
    }
}


/************* Trash Change **************/

function changetrash(url)
{
    //alert("in");
    var srhtxt = document.getElementById('txtsearch').value;
    var trash_type=document.getElementById('fk_manuglcode').value;
    //alert(url+"?trash_type="+trash_type+ 'gridbody');
    sendPagingRequest(url,"?paging=yes&pagesize=10&pagenumber=1&trash_type="+trash_type+ "&order_field=intglcode&order_type=asc&srhtxt=", 'gridbody');
}
/****************************************/

/************* search field **************/
function gridSearch(url, pagesize, pageno, orderfield, ordertype)
{
    //alert(ordertype);
    var srhtxt = document.getElementById('txtsearch').value;
    //alert(srhtxt);
    //alert(url + "?paging=yes&pagenumber=" + pageno + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt);
    sendPagingRequest(url, "?paging=yes&pagesize=" + pagesize + "&pagenumber=" + pageno + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
}
function gridSearch1(url, pagesize, pageno, orderfield, ordertype)
{
    //alert("in");
    var srhtxt = document.getElementById('txtsearch').value;
    var trash_type=document.getElementById('fk_manuglcode').value;
    //alert(url + "?paging=yes&pagenumber=" + pageno + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt);
    sendPagingRequest(url, "?paging=yes&pagesize=" + pagesize + "&pagenumber=" + pageno +"&trash_type="+trash_type+ "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
}
/****************************************/

/*********** testimonials approval *************/
function approveTestimonials(url, pagesize, pageno, orderfield, ordertype, srhtxt)
{
    var chkelements = document.getElementsByName('chkapprove');
    var approveids = "";
    var disapproveids = "";
    var countchecked = 0;
	
    for(var i = 0; i < chkelements.length; i++)
    {
        if(chkelements.item(i).checked)
        {
            countchecked++;
			
            if(approveids != "")
                approveids += ",";
            approveids += chkelements.item(i).value;
        }
        else
        {
            if(disapproveids != "")
                disapproveids += ",";
            disapproveids += chkelements.item(i).value;
        }
    }
	

    //alert("approveids : " + approveids + " disapproveids : " + disapproveids);
    sendPagingRequest(url, "?action=approve&approveids="+ approveids + "&disapproveids=" + disapproveids + "&paging=yes&pagesize=" + pagesize + "&pagenumber=" + pageno + "&order_field=" + orderfield + "&order_type=" + ordertype + "&srhtxt=" + srhtxt, 'gridbody');
}

/******* quick edit functions *******/
function enableQuickEdit(intglcode)
{
    var label = "label_" + intglcode;
    var widget = "widget_" + intglcode;
	
    var update = "update_" + intglcode;
    var edit = "edit_" + intglcode;
    document.getElementById(edit).style.display = "none";
    document.getElementById(update).style.display = "";
	
    var elements = document.getElementsByTagName("span");
    for(var i = 0; i < elements.length; i++)
    {
        if(elements[i].id)
        {
            if(elements[i].id == label)
            {
                elements[i].style.display = "none";
            }
            else if(elements[i].id == widget)
            {
                elements[i].style.display = "";
            }
        }
    }
}

function cancelQuickEdit(intglcode)
{
    var label = "label_" + intglcode;
    var widget = "widget_" + intglcode;
	
    var update = "update_" + intglcode;
    var edit = "edit_" + intglcode;
    document.getElementById(edit).style.display = "";
    document.getElementById(update).style.display = "none";
	
    var elements = document.getElementsByTagName("span");
    for(var i = 0; i < elements.length; i++)
    {
        if(elements[i].id)
        {
            if(elements[i].id == label)
            {
                elements[i].style.display = "";
            }
            else if(elements[i].id == widget)
            {
                elements[i].style.display = "none";
            }
        }
    }
}
/****************************************/
function call_search_keypress(e,idredirect)
{
	
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch='';
    var KeyID = '';
    //alert(_dom);
    if(_dom==2){                     // for NN4
        //alert(e.which);
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            //alert('Mozilla:' + e.charCode);
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }
    //alert(idredirect);
	
    if(e.keyCode == 13)
    {
        //alert(document.getElementById("hrefgridsearch").onclick=true);
        //alert(idredirect);
        document.getElementById(idredirect).onclick();
    //return true;
    }
    else
    {
        return false;
    }
    return true;
}  
function isDate(str)
{
	  
    var re = /^(\d{1,2})[\s\.\/-](\d{1,2})[\s\.\/-](\d{4})$/
    //var re = /^([0]?[1-9]|[1][0-2])[./-]([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]([0-9]{4}|[0-9]{2})$/
    if (!re.test(str)) return false;
    var result = str.match(re);
    //alert(result[4]);
    var y = parseFloat(result[3]);
    var m = parseFloat(result[1]);
    var d = parseFloat(result[2]);
    //  var rsplit = result[0].split('/');
    //  var y = parseFloat(rsplit[2]);
    //  var m = parseFloat(rsplit[0]);
    //  var d = parseFloat(rsplit[1]);
    //
    //  alert(y);
    //  alert(m);
    //  alert(d);
	
    if(m < 1 || m > 12 || y < 1900 || y > 2100) return false;
    if(m == 2)
    {
        var days = ((y % 4) == 0) ? 29 : 28;
    }
    else if(m == 4 || m == 6 || m == 9 || m == 11)
    {
        var days = 30;
    }
    else
    {
        var days = 31;
    }
    return (d >= 1 && d <= days);
}

function getshrmodel(varmenu,var_type)
{
	
    var targetdiv="shr_div_model";
    //alert(varmenu);
    if(var_type==1)
    {
        //alert("in");
        //alert(varmenu);
        //alert(var_type);
        sendPagingRequest('ajax_data.php', '?shr_menufact='+varmenu+"&var_switch_type=getbodyindex", targetdiv);
    }
    else
    {
        sendPagingRequest('ajax_data.php', '?shr_menufact='+varmenu+"&var_switch_type=getbodyinner", targetdiv);
    }
}

function getshrbody(varmenu)
{
    var targetdiv="shr_div_body";
    //alert(varmenu);
    sendPagingRequest('ajax_data.php', '?fk_manuglcode='+varmenu+"&var_switch_type=getshrbody", targetdiv)
}

function get_model_summary()
{
    //alert("in");
    var model_id=document.getElementById('fk_modelglcode').value;
    //alert(model_id);
    sendPagingRequest('modelcolor.php','?paging=true&fk_modelglcode='+model_id,'gridbody');
	
//window.location.href="modelsummary.php?fk_modelglcode="+model_id;
}



function get_model()
{
    //alert("in");
    model_id=document.getElementById('uid').value;
    //alert(model_id);
    var param='?userdo=Edit&pagging=true&uid='+model_id+'&pagenumber=&order_field=&order_type=&srhtxt=';
    //alert(param);
    sendPagingRequest_model('modelfk.php',param,'fkediter');
//window.location.href="modelsummary.php?fk_modelglcode="+model_id;
}

function sendPagingRequest_model(url, parameters, targetdiv)
{
    //alert(url);
    //alert(parameters);
    //alert(targetdiv);
    xmlHttp = GetXmlHttpObject();
	
    if(xmlHttp != null)
    {
		
        xmlHttp.onreadystatechange = function() {
			
            SetBackground(); // set dimmer
			
            if(xmlHttp.readyState==1)
            {
                ProcessLoader(); // set loading text
            }
			
            if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
            {
				
                var str =  xmlHttp.responseText;
                //alert(str);
                if(url=="ajax_data.php")
                {
                    document.getElementById(targetdiv).innerHTML =str;
                }
                else
                {
                    var strarray = str.split("*****");
                    //alert(strarray[1]);
                    document.getElementById(targetdiv).innerHTML = strarray[1];
                }
                //listing1('trash.php', 10);
                UnsetBackground(); //Remove Loader
            }
        };

        xmlHttp.open('GET', url + parameters, true);
        xmlHttp.send(null);
    }
    else
    {
        alert("Your browser does not support HTTP Request");
    }
}
function add_model_color()
{
    //alert("in");
    var model_id=document.getElementById('fk_modelglcode').value;
    var color_id=document.getElementById('input_field_1').value;
    color_id=color_id.substring(1);
    //alert(model_id);
    sendPagingRequest('modelcolor.php','?paging=true&fk_modelglcode='+model_id+'&color_id='+color_id,'gridbody');
	
//window.location.href="modelsummary.php?fk_modelglcode="+model_id;
}
/*function show_hide_bar(varsrc,vararrowid,varsidebarid)
{
	alert(document.getElementById(varsidebarid).style.display=='');
	if(document.getElementById(varsidebarid).style.display=='')
	{
		document.getElementById(varsidebarid).style.display='none';
	}
	else
	{
		document.getElementById(varsidebarid).style.display='block';
	}
	
}*/

function reloadlist()
{


    location.reload( true );

}

function requestquoteform_special(intglcode_special)
{
    //alert('dadasd');
    xmlHttp=GetXmlHttpObject()
    if(xmlHttp==null)
    {
        alert("Browser does not support HTTP Request")
        return
    }
    //var url="loginpopup.php"
    //url=url+"?frmid="+str
    //url=url+"&sid="+Math.random()
    var url="requestquotespecial.php";
    url=url+"?intglcode="+intglcode_special;
    xmlHttp.onreadystatechange= staterequestquote_special
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)

}
function staterequestquote_special()
{
    SetBackground();
    //alert(xmlHttp.readyState);
    //alert(xmlHttp.responseText);
    if(xmlHttp.readyState==1)
    {
        ProcessLoader();
    }
    if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {
        <!--document.getElementById('dvprocessing').style.display='none';-->
        //alert(xmlHttp.responseText);
        var popuph = 494;
        var popupw = 371;
        var popuph2 = popuph/2;
        var popupw2 = popupw/2;
        var winW = screen.width;
        var winH = screen.height;
        if (parseInt(navigator.appVersion)>3) {
            if (navigator.appName=="Netscape") {
                //winW = window.innerWidth;
                //winH = window.innerHeight;
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }
            if (navigator.appName.indexOf("Microsoft")!=-1) {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            //winW = window.innerWidth;
            //winH = window.innerHeight;
            }

        }
        //alert(window.innerWidth + ":" + window.innerHeight );
        var sh = winH;
        var sw = winW;
        var sh2 = sh/2;
        var sw2 = sw/2;

        var topf = sh2 - popuph;
        var leftf = sw2 - popupw2;


        //alert(popuph2 + ":" + popuph + ":" + sh2 + ":" + sh + ":" + topf);
        //alert(popupw2 + ":" + popupw + ":" + sw2 + ":" + sw + ":" + leftf);


        document.getElementById('dvprocessing').style.display='none';
        document.getElementById('dvregisterfrm').style.display='';
        document.getElementById('dvregisterfrm').style.height=popuph;
        document.getElementById('dvregisterfrm').style.width=popupw;

        //document.getElementById('dvregisterfrm').style.top=CalculateTop('316')+ "px";
        //document.getElementById('dvregisterfrm').style.left=CalculateLeft('392')+ "px";

        // binit comment
        /*document.getElementById('dvregisterfrm').style.top= topf + "px";
*/
        document.getElementById('dvregisterfrm').style.top=CalculateTop('450')+ "px";
        //document.getElementById('dvregisterfrm').style.top=CalculateTop('211')+ "px";
        // binit comment end
        document.getElementById('dvregisterfrm').style.left= leftf + "px";
        //alert(document.getElementById('dvregisterfrm').style.height);
        //alert(document.getElementById('dvregisterfrm').style.width);
        document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;
        unhideIframe();
    }

}

function  form_submit_requestquote_special()
{
    var testresults;
    var str=document.requestquot.varemail.value;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str))
        testresults=true
    else{

        testresults=false
    }
    function trim(str, chars) {
        return ltrim(rtrim(str, chars), chars);
    }
    function ltrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
    }
    function rtrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
    }

    //alert(isDate(document.getElementById('dtpreferreddate').value);

    if(trim(document.getElementById('varname').value)=="")
    {
        alert("Please Enter Your Name");
        document.getElementById('varname').focus();
        return false;
    }
    else if(trim(document.getElementById('varemail').value)=="")
    {
        alert("Please Enter Your Email");
        document.getElementById('varemail').focus();
        return false;
    }
    else if(testresults==false)
    {
        alert("Please Enter Proper Email");
        document.getElementById('varemail').focus();
        return false;
    }
    else if(document.requestquot.txtimage.value=="Enter the Code")
    {
        alert("Please enter the code shown above ");
        document.requestquot.txtimage.focus();
        return false;
    }
    else if(document.requestquot.txtimage.value!=document.requestquot.pin_value_hdn.value)
    {
        alert("Please Enter The Given Code Correctly");
        document.requestquot.txtimage.focus();
        return false;
    }




    //document.registration_form.submit();
    //document.registration_form.edit_refresh.value = '1';
    //fillRequest();
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request.");
        return;
    }

    var url="requestquotespecial.php?QT=1";



    var params = "&varname="+document.getElementById('varname').value;


    //params=params+ "&varcompanyname="+document.getElementById('varcompanyname').value;
    params=params+"&varemail="+document.getElementById('varemail').value;
    // params=params+"&status="+document.getElementById('status').value;

    params=params+"&varmessage="+document.getElementById('varmessage').value;

    params=params+"&varphone="+document.getElementById('varphone').value;
    params=params+"&intglcode="+document.getElementById('intglcode').value;
	

    xmlHttp.open("GET",url +params ,true)

    xmlHttp.onreadystatechange=submit_staterequestquote_special;
    xmlHttp.send(null);
}
function submit_staterequestquote_special()
{

    SetBackground();

    if (xmlHttp.readyState == 1)
    {
        ProcessLoader();
    }

    if ((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {

        document.getElementById('dvprocessing').style.display = 'none';


        //var str = trim(xmlHttp.responseText, ' ');

        //var strlengthcount = str.length;
        //alert("1");

        var popuph = 494;
        var popupw = 371;

        var popuph2 = popuph/2;
        var popupw2 = popupw/2;
        var winW = screen.width;
        var winH = screen.height;

        if (parseInt(navigator.appVersion)>3) {
            if (navigator.appName=="Netscape") {

                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }
            if (navigator.appName.indexOf("Microsoft")!=-1) {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;

            }

        }

        var sh = winH;
        var sw = winW;
        var sh2 = sh/2;
        var sw2 = sw/2;

        var topf1 = sh2 - popuph;
        var leftf1 = sw2 - popupw2;

        document.getElementById('dvprocessing').style.display='none';
        document.getElementById('dvregisterfrm').style.display='';
        document.getElementById('dvregisterfrm').style.top=CalculateTop('470')+ "px";
        document.getElementById('dvregisterfrm').style.height=popuph;
        document.getElementById('dvregisterfrm').style.width=popupw;
        document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;
        styledPopupClose();
    //alert(xmlHttp.responseText);

    }

}

function requestquoteform(intglcode)
{
    xmlHttp=GetXmlHttpObject()
    if(xmlHttp==null)
    {
        alert("Browser does not support HTTP Request")
        return
    }
    //var url="loginpopup.php"
    //url=url+"?frmid="+str
    //url=url+"&sid="+Math.random()
    var url="requestquote.php";
    url=url+"?intglcode="+intglcode;
    xmlHttp.onreadystatechange= staterequestquote
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)

}

function staterequestquote()
{
    SetBackground();
    //alert(xmlHttp.readyState);
    //alert(xmlHttp.responseText);
    if(xmlHttp.readyState==1)
    {
        ProcessLoader();
    }
    if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {
        <!--document.getElementById('dvprocessing').style.display='none';-->
        //alert(xmlHttp.responseText);
        var popuph = 494;
        var popupw = 371;
        var popuph2 = popuph/2;
        var popupw2 = popupw/2;
        var winW = screen.width;
        var winH = screen.height;
        if (parseInt(navigator.appVersion)>3) {
            if (navigator.appName=="Netscape") {
                //winW = window.innerWidth;
                //winH = window.innerHeight;
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }
            if (navigator.appName.indexOf("Microsoft")!=-1) {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            //winW = window.innerWidth;
            //winH = window.innerHeight;
            }

        }
        //alert(window.innerWidth + ":" + window.innerHeight );
        var sh = winH;
        var sw = winW;
        var sh2 = sh/2;
        var sw2 = sw/2;

        var topf = sh2 - popuph;
        var leftf = sw2 - popupw2;


        //alert(popuph2 + ":" + popuph + ":" + sh2 + ":" + sh + ":" + topf);
        //alert(popupw2 + ":" + popupw + ":" + sw2 + ":" + sw + ":" + leftf);


        document.getElementById('dvprocessing').style.display='none';
        document.getElementById('dvregisterfrm').style.display='';

        document.getElementById('dvregisterfrm').style.height=popuph;
        document.getElementById('dvregisterfrm').style.width=popupw;

        //document.getElementById('dvregisterfrm').style.top=CalculateTop('316')+ "px";
        //document.getElementById('dvregisterfrm').style.left=CalculateLeft('392')+ "px";

        // binit comment
        /*document.getElementById('dvregisterfrm').style.top= topf + "px";
*/
        document.getElementById('dvregisterfrm').style.top=CalculateTop('450')+ "px";
        //document.getElementById('dvregisterfrm').style.top=CalculateTop('211')+ "px";
        // binit comment end
        document.getElementById('dvregisterfrm').style.left= leftf + "px";
        //alert(document.getElementById('dvregisterfrm').style.height);
        //alert(document.getElementById('dvregisterfrm').style.width);
        document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;
        unhideIframe();
    }
}
function form_submit_requestquote()
{


    var testresults;
    var str=document.requestquot.varemail.value;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str))
        testresults=true
    else{

        testresults=false
    }
    function trim(str, chars) {
        return ltrim(rtrim(str, chars), chars);
    }
    function ltrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
    }
    function rtrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
    }
    //alert(isDate(document.getElementById('dtpreferreddate').value);

    if(trim(document.getElementById('varname').value)=="")
    {
        alert("Please Enter Your Name");
        document.getElementById('varname').focus();
        return false;
    }
    else if(trim(document.getElementById('varemail').value)=="")
    {
        alert("Please Enter Your Email");
        document.getElementById('varemail').focus();
        return false;
    }
    else if(testresults==false)
    {
        alert("Please Enter  proper Your Email");
        document.getElementById('varemail').focus();
        return false;
    }
    else if(document.requestquot.txtimage.value=="Enter the Code")
    {
        alert("Please enter the code shown above ");
        document.requestquot.txtimage.focus();
        return false;
    }
    else if(document.requestquot.txtimage.value!=document.requestquot.pin_value_hdn.value)
    {
        alert("Please Enter The Given Code Correctly");
        document.requestquot.txtimage.focus();
        return false;
    }

	


    //document.registration_form.submit();
    //document.registration_form.edit_refresh.value = '1';
    //fillRequest();
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Browser does not support HTTP Request.");
        return;
    }

    var url="requestquote.php?QT=1";

       

    var params = "&varname="+document.getElementById('varname').value;

		
    //params=params+ "&varcompanyname="+document.getElementById('varcompanyname').value;
    params=params+"&varemail="+document.getElementById('varemail').value;
    // params=params+"&status="+document.getElementById('status').value;

    params=params+"&varmessage="+document.getElementById('varmessage').value;
		
    params=params+"&varphone="+document.getElementById('varphone').value;
    params=params+"&intglcode="+document.getElementById('intglcode').value;

    xmlHttp.open("GET",url +params ,true)

    xmlHttp.onreadystatechange=submit_staterequestquote;
    xmlHttp.send(null);
}

function submit_staterequestquote()
{

    SetBackground();

    if (xmlHttp.readyState == 1)
    {
        ProcessLoader();
    }

    if ((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {

        alert('The message has been successfully sent.');
        document.getElementById('dvprocessing').style.display = 'none';
        popupclosed();
        
    }
 
 
    function emailafriendformxxx(intglcode)
    {
        alert(intglcode);
        xmlHttp=GetXmlHttpObject()
        if(xmlHttp==null)
        {
            alert("Browser does not support HTTP Request")
            return
        }
        //var url="loginpopup.php"
        //url=url+"?frmid="+str
        //url=url+"&sid="+Math.random()
        var url="emailafriend.php";
        url=url+"?intglcode="+intglcode;
        xmlHttp.onreadystatechange= stateemailafriend
        xmlHttp.open("GET",url,true)
        xmlHttp.send(null)

    }

    function stateemailafriend()
    {
        SetBackground();
        //alert(xmlHttp.readyState);
        //alert(xmlHttp.responseText);
        if(xmlHttp.readyState==1)
        {
            ProcessLoader();
        }
        if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
            <!--document.getElementById('dvprocessing').style.display='none';-->
            //alert(xmlHttp.responseText);
            var popuph = 494;
            var popupw = 371;
            var popuph2 = popuph/2;
            var popupw2 = popupw/2;
            var winW = screen.width;
            var winH = screen.height;
            if (parseInt(navigator.appVersion)>3) {
                if (navigator.appName=="Netscape") {
                    //winW = window.innerWidth;
                    //winH = window.innerHeight;
                    winW = document.body.offsetWidth;
                    winH = document.body.offsetHeight;
                }
                if (navigator.appName.indexOf("Microsoft")!=-1) {
                    winW = document.body.offsetWidth;
                    winH = document.body.offsetHeight;
                //winW = window.innerWidth;
                //winH = window.innerHeight;
                }

            }
            //alert(window.innerWidth + ":" + window.innerHeight );
            var sh = winH;
            var sw = winW;
            var sh2 = sh/2;
            var sw2 = sw/2;

            var topf = sh2 - popuph;
            var leftf = sw2 - popupw2;


            //alert(popuph2 + ":" + popuph + ":" + sh2 + ":" + sh + ":" + topf);
            //alert(popupw2 + ":" + popupw + ":" + sw2 + ":" + sw + ":" + leftf);


            document.getElementById('dvprocessing').style.display='none';
            document.getElementById('dvregisterfrm').style.display='';
            //document.getElementById('dvregisterfrm').style.height=10;
            //document.getElementById('dvregisterfrm').style.width=10;

            //document.getElementById('dvregisterfrm').style.top=CalculateTop('316')+ "px";
            //document.getElementById('dvregisterfrm').style.left=CalculateLeft('392')+ "px";

            // binit comment
            /*document.getElementById('dvregisterfrm').style.top= topf + "px";
*/
            document.getElementById('dvregisterfrm').style.top=CalculateTop('450')+ "px";
            //document.getElementById('dvregisterfrm').style.top=CalculateTop('211')+ "px";
            // binit comment end
            document.getElementById('dvregisterfrm').style.left= leftf + "px";
            //alert(document.getElementById('dvregisterfrm').style.height);
            //alert(document.getElementById('dvregisterfrm').style.width);
            document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;
            unhideIframe();
        }
    }
    function form_submit_emailafriend()
    {


        var testresults;
        var str=document.emailafriend.varemail.value;
        var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
        if (filter.test(str))
            testresults=true
        else{

            testresults=false
        }
        function trim(str, chars) {
            return ltrim(rtrim(str, chars), chars);
        }
        function ltrim(str, chars) {
            chars = chars || "\\s";
            return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
        }
        function rtrim(str, chars) {
            chars = chars || "\\s";
            return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
        }

        //alert(isDate(document.getElementById('dtpreferreddate').value);

        if(trim(document.getElementById('varyouremail').value)=="")
        {
            alert("Please Enter the Your Email");
            document.getElementById('varyouremail').focus();
            return false;
        }
        else if(trim(document.getElementById('varemail').value)=="")
        {
            alert("Please Enter the Email");
            document.getElementById('varemail').focus();
            return false;
        }
        else if(testresults==false)
        {
            alert("Please Enter Proper Email");
            document.getElementById('varemail').focus();
            return false;
        }
        else if(document.emailafriend.txtimage.value=="Enter the Code")
        {
            alert("Please enter the code shown above ");
            document.emailafriend.txtimage.focus();
            return false;
        }
        else if(document.emailafriend.txtimage.value!=document.emailafriend.pin_value_hdn.value)
        {
            alert("Please Enter The Given Code Correctly");
            document.emailafriend.txtimage.focus();
            return false;
        }

	


        //document.registration_form.submit();
        //document.registration_form.edit_refresh.value = '1';
        //fillRequest();
        xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null)
        {
            alert ("Browser does not support HTTP Request.");
            return;
        }

        var url="emailafriend.php?QT=1";

       

        var params = "&varyouremail="+document.getElementById('varyouremail').value;

		
        //params=params+ "&varcompanyname="+document.getElementById('varcompanyname').value;
        params=params+"&varemail="+document.getElementById('varemail').value;
        // params=params+"&status="+document.getElementById('status').value;

        params=params+"&varmessage="+document.getElementById('varmessage').value;
		
        params=params+"&intglcode="+document.getElementById('intglcode').value;

        xmlHttp.open("GET",url +params ,true)

        xmlHttp.onreadystatechange=submit_stateemailafriend;
        xmlHttp.send(null);
    }

    function submit_stateemailafriend()
    {

        SetBackground();

        if (xmlHttp.readyState == 1)
        {
            ProcessLoader();
        }

        if ((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
        {
	 
            document.getElementById('dvprocessing').style.display = 'none';


            var str = trim(xmlHttp.responseText, ' ');
	
            var strlengthcount = str.length;

	
            var popuph = 494;
            var popupw = 371;

            var popuph2 = popuph/2;
            var popupw2 = popupw/2;
            var winW = screen.width;
            var winH = screen.height;

            if (parseInt(navigator.appVersion)>3) {
                if (navigator.appName=="Netscape") {

                    winW = document.body.offsetWidth;
                    winH = document.body.offsetHeight;
                }
                if (navigator.appName.indexOf("Microsoft")!=-1) {
                    winW = document.body.offsetWidth;
                    winH = document.body.offsetHeight;

                }

            }

            var sh = winH;
            var sw = winW;
            var sh2 = sh/2;
            var sw2 = sw/2;

            var topf1 = sh2 - popuph;
            var leftf1 = sw2 - popupw2;

            document.getElementById('dvprocessing').style.display='none';
            document.getElementById('dvregisterfrm').style.display='';
            document.getElementById('dvregisterfrm').style.top=CalculateTop('470')+ "px";

            document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;
            unhideIframe();
        
        }
    }
 
}




function submit_request_quta()
{
    	
    var testresults;
    var str=document.getElementById('varemail').value;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str))
        testresults=true
    else{

        testresults=false
    }

    function trim(str, chars) {
        return ltrim(rtrim(str, chars), chars);
    }
    function ltrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
    }
    function rtrim(str, chars) {
        chars = chars || "\\s";
        return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
    }

       
    
    if(trim(document.getElementById('varname').value)=="" || document.getElementById('varname').value=="Name")
    {
        alert("Please enter your name");
        document.getElementById('varname').focus();
        return false;
    }
    else if(trim(document.getElementById('varemail').value=="" || document.getElementById('varemail').value)=="Email")
    {
        alert("Please enter your email addres");
        document.getElementById('varemail').focus();
        return false;
    }
    else if(testresults==false)
    {
        alert("Please enter proper email");
        document.getElementById('varemail').focus();
        return false;
    }
    else if(document.getElementById('varmessage').value=="")
    {
        alert("Please enter message");
        document.getElementById('varmessage').focus();
        return false;
    }
    else if(document.getElementById('txtimage_C').value=="" || document.getElementById('txtimage_C').value=="Enter the Code")
    {
        alert("Please enter the given code");
        document.getElementById('txtimage_C').focus();
        return false;
    }
    else if(document.getElementById('txtimage_C').value!=document.getElementById('hid_generatepin_C').value)
    {
        alert("Please enter the given code correctly");
        document.getElementById('txtimage_C').focus();
        return false;
    }
	
    //alert("in1");
    xmlHttp=GetXmlHttpObject()
    if(xmlHttp==null)
    {
        alert("Browser does not support HTTP Request")
        return
    }
    var url="send_req.php";
    url=url+"?req_type="+document.getElementById('req_type').value;
    url=url+"&varname="+document.getElementById('varname').value;
    url=url+"&varemail="+document.getElementById('varemail').value;
    url=url+"&varmessage="+document.getElementById('varmessage').value;
    url=url+"&hdadmin1="+document.getElementById('hdadmin1').value;
    url=url+"&hdadmin2="+document.getElementById('hdadmin2').value;
    url=url+"&hdadmin3="+document.getElementById('hdadmin3').value;
	url=url+"&txtimage_C="+document.getElementById('txtimage_C').value;
    url=url+"&hid_generatepin_C="+document.getElementById('hid_generatepin_C').value;
    //alert(url);
    //url=url+"?req_type="+req_type;
    xmlHttp.onreadystatechange= submit_statechangerequest
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)

}


function submit_statechangerequest()
{

    SetBackground();
	
    if (xmlHttp.readyState == 1)
    {
        ProcessLoader();
    }
	
    if ((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {
        //		 alert(xmlHttp.responseText);
        alert("Thankyou for your Request we will get back to you shortly.");
        window.location.reload( false );
    }
}
 
function body_onkeydown(evt)

{

    var key=(window.Event)?evt.which:evt.keyCode;

    if(key==27)

    {

        styledPopupClose();

    }

}

function close_request_quote(e)
{
    //alert("in");
	
    //alert(e.keyCode);
	
    if(e.keyCode == 27)
    {
        
        closeSlidePanel('formElement');
		
    }
    else if(e.keyCode == 13)
    {
        submit_request_quta();
        return false;
    }
    else
    {
        return true;
    }
    return true;
}

function showrmortgagecalc()
{	
    xmlHttp=GetXmlHttpObject()
    if(xmlHttp==null)
    {
        alert("Browser does not support HTTP Request.")
        return
    }
    var url="mortgagecalc.php";
    xmlHttp.onreadystatechange= stateChange_mortgagecalc
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)

}

function stateChange_mortgagecalc()
{

    SetBackground();
    //alert('test');
    if(xmlHttp.readyState==1)
    {
        ProcessLoader();
    }
    if((xmlHttp.readyState==4||xmlHttp.readyState=="complete")&&(xmlHttp.status==200))
    {

        document.getElementById('dvprocessing').style.display='none';

        var popuph = 309;
        var popupw = 305;
        var popuph2 = popuph/2;
        var popupw2 = popupw/2;
        var winW = screen.width;
        var winH = screen.height;
        if (parseInt(navigator.appVersion)>3) {
            if (navigator.appName=="Netscape") {
                //winW = window.innerWidth;
                //winH = window.innerHeight;
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }
            if (navigator.appName.indexOf("Microsoft")!=-1) {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            //winW = window.innerWidth;
            //winH = window.innerHeight;
            }

        }

        var sh = winH;
        var sw = winW;
        var sh2 = sh/2;
        var sw2 = sw/2;

        var topf = sh2 - popuph;
        var leftf = sw2 - popupw2;



        document.getElementById('dvprocessing').style.display='none';
        document.getElementById('dvregisterfrm').style.display='';
        document.getElementById('dvregisterfrm').style.height=10;
        document.getElementById('dvregisterfrm').style.width=10;

        document.getElementById('dvregisterfrm').style.top=CalculateTop('530')+ "px";

        document.getElementById('dvregisterfrm').style.left= leftf + "px";

        document.getElementById("dvregisterfrm").innerHTML=xmlHttp.responseText;


        setfocus_onform();

        unhideIframe();


    }
}

function chkprice(e)
{
    //alert("testing");
    var _dom = 0;
    _dom=document.all?3:(document.getElementById?1:(document.layers?2:0));
    if(document.all) e=window.event; // for IE
    var ch = '';
    var KeyID = '';
    //alert(_dom);
    if(_dom==2){                     // for NN4
        //alert(e.which);
        if(e.which>0) ch='('+String.fromCharCode(e.which)+')';
        KeyID=e.which;
    }
    else
    {
        if(_dom==3){                   // for IE
            KeyID = (window.event) ? event.keyCode : e.which;
        }
        else {                       // for Mozilla
            //alert('Mozilla:' + e.charCode);
            if(e.charCode>0) ch='('+String.fromCharCode(e.charCode)+')';
            KeyID=e.charCode;
        }
    }

    if(KeyID==46)
    {
        return true;
    }
    else if((KeyID >= 65 && KeyID <= 90) || (KeyID >= 97 && KeyID <= 122) || (KeyID >= 33 && KeyID <= 47) || (KeyID >= 58 && KeyID <= 64) || (KeyID >= 91 && KeyID <= 96) || (KeyID >= 123 && KeyID <= 126))
    {
        //alert("hello");
        return false;
    }


    return true;
}
function popupclosed()
{
    document.getElementById("dvregisterfrm").style.display = "none";
    document.getElementById('dimmer').style.visibility = 'hidden';
}


var popupWindow = null;
function positionedPopup(url,winName,w,h,t,l,scroll){
    settings =
    'height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+scroll+',resizable'
    popupWindow = window.open(url,winName,settings)
}

function getAmortization(a,n,p)
{
               
    if (document.getElementById('terminY').checked)
    {
        n = n * 12;
    }

    var i=0;
    var sATline="";
    /*var oAmortizationTable=document.getElementById("amortizationtable");
oAmortizationTable.style.visibility="visible";*/

    /* Calculate amortization and write table to text area **/
    var payment = getPayment(a,n,p);
    var oAmortizationTable=document.getElementById("amortizationtable");
    oAmortizationTable.value = "Your monthly payment for a " + n + " month loan at " + p + "% would be " + (Math.round(payment*100)/100);
}
function getPayment(a,n,p) {
    /* Calculates the monthly payment from annual percentage
rate, term of loan in months and loan amount. **/
    var acc=0;
    var base = 1 + p/1200;
    for (i=1;i<=n;i++)
    {
        acc += Math.pow(base,-i);
    }
    return a/acc;
}
function CheckYears()
{
                
    document.getElementById('terminM').checked = "";
}
function CheckMonths()
{
                
    document.getElementById('terminY').checked = "";
}

