function PrintPage(){	
	if (window.location.href.indexOf("?") == -1 ) { 
	openwin(window.location.href + '?mode=print',25,25);
	}else{
	  openwin(window.location.href + '&mode=print',25,25);  
	 }
    
}

function openwin(url, tmp3, tmp4){
	scn_w = screen.availwidth;
	scn_h = screen.availheight;
	pos_x = (scn_w - tmp3)/2 - 20;
	pos_y = (scn_h - tmp4)/2;
	show3 = window.open( url,'show','width='+ tmp3 +',height='+ tmp4 +',top='+ pos_y +',left='+ pos_x +',resizable=0,scrollbars=auto,directories=0,toolbar=0,menubar=0');
	window.show3.focus();
}

function RevalidatePage() {
    if ($("#Invalidfields").is(':visible')) {
        ValidatePage();
        ValidateCustoms();
    }
}

function ValidatePage() {
    if (typeof (Page_ClientValidate) == 'function') {
        Page_ClientValidate();
    }
    if (Page_IsValid) {
        $("#Invalidfields").hide();
    } else {
        //set label visible
        $("#Invalidfields").show();
    }
}

function ValidateCustoms() {
    $('#form1').validate();
    if (!$('#form1').valid()) {
        $("#Invalidfields").show();
        return false;
    }
    else {
        $("#Invalidfields").hide();
        return true;
    }
}

function GetPriceByOptions(prodID) {
    
    $('.ProductPrice').html("<img src='/images/layout/loading.gif'>");

    var options = "";
    var optSep = ""
    //for 'input[name^="news"]'
    $("[id^='prodopt_']").each(function (index) {
        var optvalue = $(this).val();
        if (optvalue != "") {
            var useItem = true;
            //check voor type checkbox, dus only if checked dan meesturen
            if ($(this).attr('type') == 'radio') {
                if (!this.checked) {
                    //alert('test');
                    useItem = false;
                }
            }

            if (useItem) {
                options = options + optSep + this.id + ':' + optvalue;
                optSep = "|";
            }
        }
    });

    var params = "{'productID':'" + prodID + "','options':'" + options + "'}";
    $.ajax({
        type: "POST",
        url: "/ws/dealershop.asmx/CalcPrice",
        data: params,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
           
            if (msg.d == '-1') {
                $('#DivPrice').css('visibility', 'hidden');
                $('.ProductPrice').html('-');
            } else {
                $('#DivPrice').css('visibility', 'visible');
                $('.ProductPrice').html(msg.d);             
            }
        },
        error: function (e) {
            $('#DivPrice').css('visibility', 'hidden');
        }
    });

}

