﻿function doPopup(theURL, theWinName, theLeft, theTop, theWidth, theHeight, theresize, thescrollbars, thestatusbar, themenu, thetools, thelocationbar, thedirs){
	// EXAMPLE doPopup('popup.asp', 'popwin', 10, 10, 500, 300, 'no', 'no', 'yes', 'no', 'no', 'no', 'no')
	// USE theLeft AND theTop = -1 FOR AUTO-CENTER

	if (theLeft == -1 && theTop == -1){
		theLeft = (screen.width - theWidth) / 2;
		theTop = (screen.height - theHeight) / 2;
	}
	var paramstr;
	paramstr = "width=" + theWidth + "px,height=" + theHeight + "px,left=" + theLeft + "px,top=" + theTop + "px,resizable=" + theresize + ",scrollbars=" + thescrollbars + ",status=" + thestatusbar + ",menubar=" + themenu + ",toolbar=" + thetools + ",location=" + thelocationbar + ",directories=" + thedirs;
	window.open(theURL, theWinName, paramstr);
}
function DoPopupAdvanced(TheURL, TheWidth, TheHeight,Resize,Scrollbars) {
	Resize = !Resize ? 'no' : Resize;
	Scrollbars = !Scrollbars ? 'no' : Scrollbars;
	doPopup(TheURL, 'popwin', -1, -1, TheWidth, TheHeight, Resize, Scrollbars, 'yes', 'no', 'no', 'no', 'no');
}
function downloadPDF(Url){
	window.open (Url,"coupon");
	//doPopup(Url,"coupon",100,50,766,400, 'yes', 'yes', 'yes', 'no', 'no', 'no', 'no');
}
function doPopupPrint(theURL, theWinName, theLeft, theTop, theWidth, theHeight, theresize, thescrollbars, thestatusbar, themenu, thetools, thelocationbar, thedirs){
	// EXAMPLE doPopup('popup.asp', 'popwin', 10, 10, 500, 300, 'no', 'no', 'yes', 'no', 'no', 'no', 'no')
	// USE theLeft AND theTop = -1 FOR AUTO-CENTER

	if (theLeft == -1 && theTop == -1){
		theLeft = (screen.width - theWidth) / 2;
		theTop = (screen.height - theHeight) / 2;
	}
	var paramstr;
	paramstr = "width=" + theWidth + "px,height=" + theHeight + "px,left=" + theLeft + "px,top=" + theTop + "px,resizable=" + theresize + ",scrollbars=" + thescrollbars + ",status=" + thestatusbar + ",menubar=" + themenu + ",toolbar=" + thetools + ",location=" + thelocationbar + ",directories=" + thedirs + ",media=Print";
	//alert(paramstr);
	window.open(theURL, theWinName, paramstr);
}

function SwapImage(ImageId,NewSrc,otherPath){
	var path = "Assets/Images/";
	if(otherPath){
		path = otherPath;
	}
	document.getElementById(ImageId).src = path + NewSrc;
}
var isout=true;
var defaultMenu;
function setMenuDefault(whichisDefault){
    if (whichisDefault)
		defaultMenu = whichisDefault;
	hideAll();
	if (document.getElementById(defaultMenu)) {
	    var cname = parseInt(document.getElementById(defaultMenu).className.replace("menu", "")) - 1;
	    document.getElementById(defaultMenu).className += " active";
	    if (document.getElementById("MainSubMenuWrapper").getElementsByTagName("div")[cname]) {
	        document.getElementById("MainSubMenuWrapper").getElementsByTagName("div")[cname].style.display = "block";
	    }
	} 
	clearTimeout(t);
}

var t;
function showHide(thisItem,str){
	hideAll();
	thisItem.className += " active";
	if(document.getElementById(str)){
		document.getElementById(str).style.display = "block";
	}	
}
function timersetMenuDefault() {
    clearTimeout(t);
    t = setTimeout("if (isout){setMenuDefault();}", 1000);
}

function hideAll(){
    for (i = 0; i < document.getElementById("MainMenuWrapper").getElementsByTagName("a").length; i++)
        document.getElementById("MainMenuWrapper").getElementsByTagName("a")[i].className = document.getElementById("MainMenuWrapper").getElementsByTagName("a")[i].className.replace(" active", "");
    for (i = 0; i < document.getElementById("MainSubMenuWrapper").getElementsByTagName("div").length; i++)
        document.getElementById("MainSubMenuWrapper").getElementsByTagName("div")[i].style.display = "none";
}

function NoHtmlComments(source, arguments) {
    arguments.IsValid = !arguments.Value.match(/<\s*?[^>]+\s*?>/);
}      

