﻿function clearViewState(){
    removeNode("__VIEWSTATE");
//    removeNode("__EVENTVALIDATION");
}

function removeNode(id){
    if(navigator.appName == "Microsoft Internet Explorer"){
        var el = document.getElementById(id)
        if (el)
            el.parentNode.removeNode(true)
    }
    else {
        var parent = document.getElementById(id).parentNode;
        var len = parent.childNodes.length;

        for(var i = 0; i < len; i++)
        {           
            parent.removeChild(parent.childNodes[0]);
        }
    }
}

function tbOnEnter(doAction){
    if (event.keyCode == 13){
        eval(doAction);
    }
    return false;
}
function noEnter(){
    if (event.keyCode == 13){
        return false;
    }
    return true;
}

function goToCheckoutPage(action) {
    document.getElementById("ActionName").value = action;
    clearViewState();
    theForm.action = "CheckOut.aspx";
    theForm.submit();
}

function doAction(command, action){
    var s = command.split(":");
    if (s.length == 2)
        document.getElementById(s[0]).value = s[1];
    document.getElementById("ActionName").value = action;
    theForm.submit();
}

function checkMaxLength(field, maxlimit) {
 	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}
}
function checkSPMaxLength(field, spanID, maxlimit) {
    var span = document.getElementById(spanID)
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}
	var diff = maxlimit - field.value.length;
	if (diff > 0)
	    span.innerHTML = diff + mtbM1
    else span.innerHTML = mtbM2
}

var mtbM1=' characters left. No HTML.';
var mtbM2='No characters left. No HTML.';

//Hide status bar msg javascript
function hidestatus(){
    window.status=''
    return true
}
//document.onmouseover=hidestatus
//document.onmouseout=hidestatus

function resetContactUsForm(parentForm){
    document.getElementById(parentForm + "_FullNameTextBox").value = "";
    document.getElementById(parentForm + "_EMailTextBox").value = "";
    document.getElementById(parentForm + "_PhoneTextBox").value = "";
    document.getElementById(parentForm + "_MessageTextBox").innerText = "";
}

function PopupImage(img, title) {
	w= window.open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes');	
	w.document.write("<HTML><HEAD><TITLE>"+title+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize(){if (document.images[0].complete){window.resizeTo(document.images[0].width+12,document.images[0].height+65); window.focus();}else{setTimeout('checksize()',250)}}</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src=\""+img+"\" border=0>");
	w.document.write("</BODY></HTML>");
	w.document.close();
}