var mainRowDiv;
var mainRowDiv_Lv1;
var mainRowDiv_Lv2;

$.cookie("insiderSubmition_Home");
$.cookie("insiderSubmition_SideBar");
$.cookie("contactFormSubmition");

$(document).ready(function(){
	mainRowDiv = $('#MainRow');
	mainRowDiv_Lv1 = $('#MainContainer_Lv1');
	mainRowDiv_Lv2 = $('#MainContainer_Lv2');
	
	mainRowDiv.height(mainRowDiv_Lv1.height());
	//mainRowDiv_Lv2.change(function(){alert("Changed");});
	
	$("form[globalFormValidation='true']").mouseenter(global_appendValidationInput);
	$("input[globalFormValidation='true']").keyup(global_validateUser);
	$("*[displayHiddenTextFieldOnChange]").change(displayHiddenTextFieldOnChange_Func);
	
	$(this).oneTime(3000, function() {
		mainRowDiv.height(mainRowDiv_Lv1.height());
	});
});

function openInNewWindow(newURL, type, width, height, status, modal, resizable){
	//window.open(newURL, type, 'width=600, height=340, status=no, modal=yes, resizable=yes');
	window.open(newURL, type);
}

function displayHiddenTextFieldOnChange_Func(){
	var thisObj = $(this);
	var hiddenFieldContainer = $("#" + thisObj.attr("displayHiddenTextFieldOnChange"));
	
	if(thisObj.val() == "Other")
	{
		hiddenFieldContainer.fadeIn(200);
	}else
	{
		hiddenFieldContainer.fadeOut(200);
	}
}

function global_appendValidationInput(){
	var thisObj = $(this);
	
	if(thisObj.attr("inputAdded") == 0)
	{
		thisObj.append('<input type="hidden" name="' + thisObj.attr("name") + '_inputCreated" id="' + thisObj.attr("name") + '_inputCreated" validateUserInput="true" value="0" />');
		thisObj.attr("inputAdded", 1);
	}
}

function global_validateUser(){
	var thisObj = $(this);
	var global_FormToValidateObj = $("#" + thisObj.attr("global_FormToValidate"));
	var inputID = $('#' + global_FormToValidateObj.attr("name") + '_inputCreated');
	
	if(inputID.val() == 0)
	{
		inputID.val(1);
	}
}

function validateEmails(){
	var thisObj = $(this);
	var errorText = "";
	var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if(thisObj.val() != "" & !thisObj.val().match(emailRegEx))
	{
		errorText += "Please enter a valid email address. ex. name@mail.com\r\n";
	}
	
	if(errorText != ""){
		alert(errorText); return false;
	}
}


var myImage = new Image;
myImage.src = "/graphics/recipeplus.gif";
var myImage2 = new Image;
myImage2.src = "/graphics/recipeminus.gif";
		
function showHiddenBlock(blockid){
	//alert(mainRowDiv.height() + ":" + mainRowDiv_Lv2.height() + ":" + $('#SubpageContainer').height());
	
	if (document.getElementById(blockid).style.display == 'none') {
		document.getElementById(blockid).style.display = '';
		//return true;
	} else if (document.getElementById(blockid).style.display == '') {
		document.getElementById(blockid).style.display = 'none';
		//return true;
	}
	
	mainRowDiv.height(mainRowDiv_Lv2.height() + 20);
	//alert(mainRowDiv.height() + ":" + mainRowDiv_Lv2.height() + ":" + $('#SubpageContainer').height());
}

function switchListSymbol(element) {
	if (document.getElementById(element).src.substring(document.getElementById(element).src.length - 8,document.getElementById(element).src.length) == 'down.gif') {
		document.getElementById(element).src='/graphics/arrow_orange_right.gif';
		}
	else if (document.getElementById(element).src.substring(document.getElementById(element).src.length - 9,document.getElementById(element).src.length) == 'right.gif') {
		document.getElementById(element).src='/graphics/arrow_orange_down.gif';
	}
}



//Disable right click script II (on images)- By Dynamicdrive.com
//For full source, Terms of service, and 100s DTHML scripts
//Visit http://www.dynamicdrive.com

//document.oncontextmenu=new Function("return false")  //this line alone can block right click for the whole document
var clickmessage="Right click disabled on images!";
function disableclick(e) {
if (document.all) {  //IE page here.
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
//alert(clickmessage);   //popup an alert window
event.srcElement.oncontextmenu=new Function("return false")
return false;
}
}
}
else if (document.layers) {
if (e.which == 3) {
//alert(clickmessage);
e.target.oncontextmenu=new Function("return false")
return false;
}
}
else if (document.getElementById)  //for firefox
{ 
if (e.which==3&&e.target.tagName=="IMG"){
//alert(clickmessage)
e.target.oncontextmenu=new Function("return false")
return false
}
}
}

function associateimages(){
for(i=0;i<document.images.length;i++)
document.images[i].onmousedown=disableclick;
}

if (document.all)
document.onmousedown=disableclick
else if (document.getElementById)
document.onmouseup=disableclick
else if (document.layers)
associateimages()
//////////////////--------------- end of script II

