if (window!=top){
	top.location.href=location.href;
}

var d=new Date()

function writedate_en(){
	var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	var monthname=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	document.write(weekday[d.getDay()] +" - "+ monthname[d.getMonth()] +" "+ d.getDate() +", "+ d.getFullYear())
}

function writedate_tr(){
	var weekday=new Array("Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi")
	var monthname=new Array("Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık")
	document.write(d.getDate() +" "+ monthname[d.getMonth()] +" "+ d.getFullYear() +" "+ weekday[d.getDay()])
}

function enlarge(xname,xtitle){
	window.open("/pop_photo.asp?src="+xname+"&title="+xtitle,"PHOTO","width=600,height=450,top=100,left=100,status=0,toolbar=0,directories=0,menubar=0,location=0,resizable=0,scrollbars=0");
}

function email2friend(xID,xLID){
	window.open("/pop_email_to_friend.asp?page="+ xID +"&l="+ xLID,"Email2Friend","width=500,height=300,top=100,left=100,status=0,toolbar=0,directories=0,menubar=0,location=0,resizable=1,scrollbars=0");
}

function advertise(AdverID, AdWidth, AdHeight, AdBgColor){
	google_ad_client = "pub-4648196977569231";
	google_alternate_ad_url = "http://www.tribros.com/ads/advertise.asp?a="+ AdWidth +"x"+ AdHeight +"&cbg="+ AdBgColor +"&clink=057FE7&curl=999999&ctext=666666";
	google_ad_width = AdWidth;
	google_ad_height = AdHeight;
	google_ad_format = AdWidth +"x"+ AdHeight +"_as";
	google_ad_type = "text_image";
	google_ad_channel = AdverID;
	google_color_border = AdBgColor;
	google_color_bg = AdBgColor;
	google_color_link = "057FE7";
	google_color_url = "999999";
	google_color_text = "666666";
	document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
}

// Anna's Add links
function advertisement(AdWidth, AdHeight, AdBgColor){
	google_ad_client = "pub-1058910798852224";
	google_alternate_ad_url = "http://www.tribros.com/ads/advertise.asp?a="+ AdWidth +"x"+ AdHeight +"&cbg="+ AdBgColor +"&clink=057FE7&curl=999999&ctext=666666";
	google_ad_width = AdWidth;
	google_ad_height = AdHeight;
	google_ad_format = AdWidth +"x"+ AdHeight +"_as";
	google_ad_type = "text_image";
	google_color_border = AdBgColor;
	google_color_bg = AdBgColor;
	google_ad_channel = "";
	google_color_link = "057FE7";
	google_color_url = "999999";
	google_color_text = "666666";
	document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
}

function hurriyet(){
	ad_client = "14d2826c-d1a8-4b05-8b55-dd5982fa871f";
	ad_format = "21";
	ad_width = 300;
	ad_height = 250;
	document.write('<script type="text/javascript" src="http://bumerang.hurriyet.com.tr/show_ads.js"></script>');
}
//****** FORMS *******

function isValidEmail(email, required) {
	if (required==undefined) { required=true; }
	if (email==null) { if (required) { return false; } return true; }
	if (email.length==0) { if (required) { return false; } return true; }
	if (! allValidChars(email)) { return false; }
	if (email.indexOf("@") < 1) {
		return false;
	} else if (email.lastIndexOf(".") <= email.indexOf("@")) {
		return false;
	} else if (email.indexOf("@") == email.length) {
		return false;
	} else if (email.indexOf("..") >=0) {
	return false;
	} else if (email.indexOf(".") == email.length) {
	return false;
	}
	return true;
}

function allValidChars(email) {
	var parsed = true;
	var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
	for (var i=0; i < email.length; i++) {
		var letter = email.charAt(i).toLowerCase();
		if (validchars.indexOf(letter) != -1)
		continue;
		parsed = false;
		break;
	}
	return parsed;
}

function send_email_data_validator(theForm) {
    if (! isValidEmail(theForm.fromemail.value)) {
        alert("Please enter your \"To E-mail Address\" in correct format\nexample:yourname@hotmail.com");
		theForm.fromemail.focus();
        return (false);
    }
	if (theForm.fromname.value == ""){
		alert("Please enter your \"Name\".");
		theForm.fromname.focus();
		return (false);
	}
    if (! isValidEmail(theForm.toemail.value)) {
        alert("Please enter your \"To E-mail Address\" in correct format\nexample:yourname@hotmail.com");
		theForm.toemail.focus();
        return (false);
    }
	if (theForm.toname.value == "") {
		alert("Please enter your \"Friend\'s Name\".");
		theForm.toname.focus();
		return (false);
	}
	return (true);
}

function SubmitComment(theForm) {
	if (theForm.fName.value == "" || theForm.fName.value == " " || theForm.fName.value == "  " || theForm.fName.value == "   "){
		alert("Please enter your \"Name\".");
		theForm.fName.focus();
		return (false);
	}
	if (! isValidEmail(theForm.fEmail.value)){
        alert("Please enter your \"E-mail\" in correct format\nexample:yourname@hotmail.com\n\n- Your email will not be shown to visitors.\n- Your email is required for security issues.\n- Your information will never be shared with\n third parties or any other marketing company.");
		theForm.fEmail.focus();
		return (false);
	}
	if (theForm.fComment.value == "" || theForm.fComment.value == " " || theForm.fComment.value == "  " || theForm.fComment.value == "  ") {
		alert("Please enter your \"Your Comment\".");
		theForm.fComment.focus();
		return (false);
	}
	return (true);
}

function SubmitSignUp(theForm) {
    if (! isValidEmail(theForm.femail.value)) {
        alert("Please type your \"E-mail\" in correct format\nexample:yourname@hotmail.com");
		theForm.femail.focus();
        return (false);
    }
	if (theForm.femailcon.value.length <5 ){
		alert("Please type the same e-mail address for both \"E-mail\" and \"Confim E-mail\". ");
		theForm.femailcon.focus();
		return (false);
	}
	if (theForm.femailcon.value !== theForm.femail.value ){
		alert("Please enter the same e-mail address for both \"E-mail\" and \"Confim E-mail\". ");
		theForm.femailcon.focus();
		return (false);
	}
	if (theForm.fFirstName.value == "") {
		alert("Please enter your \"First Name\".");
		theForm.fFirstName.focus();
		return (false);
	}
	if (theForm.fLastName.value == "") {
		alert("Please enter your \"Last Name\".");
		theForm.fLastName.focus();
		return (false);
	}
	if (theForm.fmonth.value == "") {
		alert("Please choose a \"Month\" for your \"Birthdate\".");
		theForm.fmonth.focus();
		return (false);
	}
	if (theForm.fday.value == "") {
		alert("Please choose a \"Day\" for your \"Birthdate\".");
		theForm.fday.focus();
		return (false);
	}
	if (theForm.fyear.value == "") {
		alert("Please choose a \"Year\" for your \"Birthdate\".");
		theForm.fyear.focus();
		return (false);
	}
	if (!theForm.agree.checked) {
		alert("Please check the agree to our terms box.");
		theForm.agree.focus();
		return false;
	}
	return (true);
}

function CheckSearchForm(theForm) {
	if (theForm.search.value=="" || theForm.search.value==" " || theForm.search.value=="  " || theForm.search.value=="   " || theForm.search.value=="    "){
		alert("Please enter at least one keyword to search!");
		theForm.search.focus();
		return (false);
	}
	return (true);
}

function PopRate(rate,ArticleID){
	window.open("/cgi-bin/article_rank_get.asp?r="+ rate +"&aid="+ ArticleID,"RankMyArticle","width=50,height=50,status=0,toolbar=0,directories=0,menubar=0,location=0,resizable=0,scrollbars=0");
}

function PopCommentArticle(ArticleID,LanID,AddComment){
	if (AddComment==1) {
	window.open("/pop_comments.asp?a="+ ArticleID +"&l="+ LanID+"#addcomment","CommentMyArticle","width=600,height=700,top=100,left=100,status=0,toolbar=0,directories=0,menubar=0,location=0,resizable=1,scrollbars=1");
	} else {
	window.open("/pop_comments.asp?a="+ ArticleID +"&l="+ LanID,"CommentMyArticle","width=600,height=700,top=100,left=100,status=0,toolbar=0,directories=0,menubar=0,location=0,resizable=1,scrollbars=1");
	}
}

function CallFlashMovie(FlashMovieID){
	document.write('<object width="400" height="335"><param name="movie" value="http://www.youtube.com/v/'+ FlashMovieID +'&autoplay=1&rel=1&color1=0x006699&color2=0x54abd6&border=0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+ FlashMovieID +'&autoplay=1&rel=1&color1=0x006699&color2=0x54abd6&border=0" type="application/x-shockwave-flash" wmode="transparent" width="400" height="335"></embed></object>');
}

function CallMagazineCover(metalan, cover){
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="450" height="600" id="LuckyNotesCover" align="middle">');
	document.write('<param name="movie" value="/swfs/cover.swf?feed='+ metalan +'&cover='+ cover +'">');
	document.write('<param name="allowScriptAccess" value="sameDomain">');
	document.write('<param name="quality" value="best">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="scale" value="noscale">');
	document.write('<param name="bgcolor" value="#333333">');
	document.write('<embed  src="/swfs/cover.swf?feed='+ metalan +'&cover='+ cover +'" quality="best" menu="false" allowScriptAccess="sameDomain" scale="noscale" bgcolor="#333333" width="450" height="600" name="LuckyNotesCover" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></object>');
}

function WriteEmail(EmailID){
	var website = "luckynotes"
	if (EmailID == '7') { 
		var emailuser = "privacy"
		document.write('<a href="mai' + 'lto:'+ emailuser +'@'+ website +'.com">'+ emailuser +'&#64;'+ website +'.com</a>');
	}
}

function write_favs(){
	document.write('<!-- AddThis Button BEGIN --><sc'+'ript language="JavaSc'+'ript" type="text/javas'+'cript">addthis_pub  = \'luckynotes\';</sc'+'ript><a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s9.addthis.com/button1-share.gif" width="125" height="16" border="0" alt=""></a><sc'+'ript type="text/javasc'+'ript" src="http://s7.addthis.com/js/152/addthis_widget.js"></sc'+'ript><!-- AddThis Button END -->');
}

function AddVideo(){
	document.write('<div id="vu_ytplayer_vjVQa1PpcFMNnPdRpeb0buKE54LfnUvELluU0vtIdog="><a href="http://www.youtube.com/browse">Watch the latest videos on YouTube.com</a></div><sc'+'ript type="text/javasc'+'ript" src="http://www.youtube.com/watch_custom_player?id=vjVQa1PpcFMNnPdRpeb0buKE54LfnUvELluU0vtIdog="></sc'+'ript>');
}


var xmlhttp;
function RateThis(rate,ArticleID) {
	xmlhttp = null;
	if (window.XMLHttpRequest) {// code for all new browsers
		xmlhttp=new XMLHttpRequest();
	} else if (window.ActiveXObject) {// code for IE5 and IE6
		xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
	}
	if (xmlhttp!=null) {
		xmlhttp.onreadystatechange = state_Change;
		xmlhttp.open('GET','/cgi-bin/article_rank_get.asp?r='+ rate +'&aid='+ ArticleID +'&sid='+ Math.random(),true);
		xmlhttp.send(null);
	} else {
		alert('Your browser does not support XMLHTTP.');
	}
}

function state_Change() {
	if (xmlhttp.readyState==4) {// 4 = "loaded"
		if (xmlhttp.status==200) {// 200 = OK
			if (IsNumeric(xmlhttp.responseText)){
//				document.checkout.fShipping.value = xmlhttp.responseText;
//				document.checkout.fZipcode.value = document.myform.fstzc.value;
//				document.getElementById('shipping').innerHTML = parseFloat(document.checkout.fShipping.value);
//				document.getElementById('totalprice').innerHTML = formatCurrency(parseFloat(document.checkout.fShipping.value)+parseFloat(document.checkout.fTotal.value));			
			} else {
				alert(xmlhttp.responseText);
			}
    	} else {
			alert('Problem retrieving XML data\nPlease try rating later.');
		}
	}
}
