// Global Variable Declarations
ns4 = (document.layers)? true:false; // netscape 4?
ie4 = (document.all)? true:false; // internet explorer 4/5?
ns6 = (ns4|ie4)? false:true; // (Netscape 6)

var isLoaded=false;

var screen_top=(screen.height/2)-(500/2);
var screen_left=(screen.width/2)-(300/2);

// Image Functions

function image_swap(in_name,in_state) {
	if (!isLoaded) {
		return true;
	}
	document.images[in_name].src = eval(in_name + "_" + in_state + ".src");
}

function loadExternal(url) {
  if ( window.frames['documentloader'] ) {
    window.frames['documentloader'].location = url;
  } 
}

// Popups

// Specific functions
function setPopupPosition(in_height,in_width) {
	screen_top=(screen.height/2)-(in_height/2);
	screen_left=(screen.width/2)-(in_width/2);
	if (screen_top<0) {
		screen_top=0;
	}
	if (screen_left<0) {
		screen_left=0;
	}
}

function blurDay() {
	if (document.forms[0].elements["BirthDay"].value=="") {
		document.forms[0].elements["BirthDay"].value="dd";
	}
}

function focusDay() {
	if (document.forms[0].elements["BirthDay"].value=="dd") {
		document.forms[0].elements["BirthDay"].value="";
	}
}

function blurYear() {
	if (document.forms[0].elements["BirthYear"].value=="") {
		document.forms[0].elements["BirthYear"].value="yyyy";
	}
}

function focusYear() {
	if (document.forms[0].elements["BirthYear"].value=="yyyy") {
		document.forms[0].elements["BirthYear"].value="";
	}
}

function blurMobileTo() {
	if (document.forms[0].elements["MobileTo"].value=="") {
		document.forms[0].elements["MobileTo"].value="Enter recipient's cell phone number";
	}
}

function focusMobileTo() {
	if (document.forms[0].elements["MobileTo"].value=="Enter recipient's cell phone number") {
		document.forms[0].elements["MobileTo"].value="";
	}
}

function blurMobileFrom() {
	if (document.forms[0].elements["MobileFrom"].value=="") {
		document.forms[0].elements["MobileFrom"].value="Enter your cell phone number";
	}
}

function focusMobileFrom() {
	if (document.forms[0].elements["MobileFrom"].value=="Enter your cell phone number") {
		document.forms[0].elements["MobileFrom"].value="";
	}
}

function submitCountryOnly() {
	document.forms[0].elements["SubmitContext"].value='CountryChange';
	document.forms[0].submit();
}

// Window openers
function openContact() {
	contact_width=435;
	if (js_ismacie) {
		contact_width=416;
	}
	contact_height=550;
	setPopupPosition(contact_width,contact_height);
	popupWin = window.open(js_root + 'home/contact.aspx','contact','width=' + contact_width + ',height=' + contact_height + ',scrollbars=yes,resize=no');
}

function openSweeps() {
	sweeps_width=435;
	if (js_ismacie) {
		sweeps_width=416;
	}
	sweeps_height=550;
	setPopupPosition(sweeps_width,sweeps_height);
	popupWin = window.open(js_root + 'home/sweeps.aspx','sweeps','width=' + sweeps_width + ',height=' + sweeps_height + ',scrollbars=yes,resize=no');
}

function openResponsibility() {
	pop_width=519;
	if (js_ismacie) {
		pop_width=500;
	}
	pop_height=550;
	setPopupPosition(pop_width,pop_height);
	popupWin = window.open(js_root + 'home/responsibility.aspx','responsibility','width=' + pop_width + ',height=' + pop_height + ',scrollbars=yes,resize=no');
}

function openSweepsRules() {
	sweeps_width=442;
	if (js_ismacie) {
		sweeps_width=423;
	}
	sweeps_height=550;
	setPopupPosition(sweeps_width,sweeps_height);
	popupWin = window.open(js_root + 'home/sweeps_rules.aspx','rules','width=' + sweeps_width + ',height=' + sweeps_height + ',scrollbars=yes,resize=no');
}

function openMuddle() {
	sweeps_width=449;
	if (js_ismacie) {
		sweeps_width=423;
	}
	sweeps_height=550;
	setPopupPosition(sweeps_width,sweeps_height);
	popupWin = window.open(js_root + 'home/muddle.aspx','muddle','width=' + sweeps_width + ',height=' + sweeps_height + ',scrollbars=yes,resize=no');
}

function openMuddleRules() {
	sweeps_width=519;
	sweeps_height=550;
	setPopupPosition(sweeps_width,sweeps_height);
	popupWin = window.open(js_root + 'home/muddle_rules.aspx','muddlerules','width=' + sweeps_width + ',height=' + sweeps_height + ',scrollbars=yes,resize=no');
}

function openRecipeSubmit() {
	recipe_width=435;
	if (js_ismacie) {
		recipe_width=416;
	}
	recipe_height=550;
	setPopupPosition(recipe_width,recipe_height);
	popupWin = window.open(js_root + 'home/recipe.aspx','recipe','width=' + recipe_width + ',height=' + recipe_height + ',scrollbars=yes,resize=no');
}

function openBarsSubmit() {
	bars_width=435;
	if (js_ismacie) {
		bars_width=416;
	}
	bars_height=550;
	setPopupPosition(bars_width,bars_height);
	popupWin = window.open(js_root + 'home/bars.aspx','bars','width=' + bars_width + ',height=' + bars_height + ',scrollbars=yes,resize=no');
}

function openSendToMobile(in_recipeguid) {
	mobile_width=420;
	mobile_height=340;
	setPopupPosition(mobile_width,mobile_height);
	popupWin = window.open(js_root + 'home/mobile.aspx?recipeguid=' + in_recipeguid,'mobile','width=' + mobile_width + ',height=' + mobile_height + ',scrollbars=no,resize=no');
}

function openSendToEmail(in_recipeguid) {
	email_width=420;
	email_height=340;
	setPopupPosition(email_width,email_height);
	popupWin = window.open(js_root + 'home/email.aspx?recipeguid=' + in_recipeguid,'email','width=' + email_width + ',height=' + email_height + ',scrollbars=no,resize=no');
}

function openRingtones(in_ringtoneid) {
	ringtones_width=435;
	if (js_ismacie) {
		ringtones_width=416;
	}
	ringtones_height=377;
	setPopupPosition(ringtones_width,ringtones_height);
	popupWin = window.open(js_root + 'home/ringtones.html?tone=' + in_ringtoneid,'ringtones','width=' + ringtones_width + ',height=' + ringtones_height + ',scrollbars=yes,resize=no');
}


// Global Init

function init() {
	
	isLoaded=true;
}

