// JavaScript Document
var tempShowedCat = "";
function showCat(id){
	
	document.getElementById("info").style.display = "none"
	if(tempShowedCat!=""){
		document.getElementById("cat"+tempShowedCat).style.display = "none"
	}
	document.getElementById("cat"+id).style.display = ""
	tempShowedCat = id;
}
function ShowResult(){
		document.getElementById('result').value= document.getElementById('headline').value+' \n\n'+document.getElementById('intro').value+' \n\n'+document.getElementById('body').value+' \n\n'+document.getElementById('info').value+' \n\n'+document.getElementById('product').value+' \n\n'+document.getElementById('contact').value+'';
}

function CountWords (this_field, show_word_count, show_char_count) {
	if (show_word_count == null) {
		show_word_count = true;
	}
	if (show_char_count == null) {
		show_char_count = false;
	}
	var char_count = this_field.value.length;
	var fullStr = this_field.value + " ";
	var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
	var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
	var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
	var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
	var splitString = cleanedStr.split(" ");
	var word_count = splitString.length -1;
	if (fullStr.length <2) {
	word_count = 0;
	}
	if (word_count == 1) {
	wordOrWords = " word";
	}
	else {
	wordOrWords = " words";
	}
	if (char_count == 1) {
	charOrChars = " character";
	} else {
	charOrChars = " characters";
	}
	if (show_word_count & show_char_count) {
	alert ("Word Count:\n" + " " + word_count + wordOrWords + "\n" + " " + char_count + charOrChars);
	}
	else {
	if (show_word_count) {
	alert ("Word Count: " + word_count + wordOrWords);
	}
	else {
	if (show_char_count) {
	alert ("Character Count: " + char_count + charOrChars);
	}
	}
	}
	return word_count;
}

function saveAs(area){
	if(document.getElementById('result').value.length!=25 && document.getElementById('result').value!=""){
		iframeWin = window.frames.content;
		iframeWin.document.open();
		iframeWin.document.open('text/html','replace')
		iframeWin.document.write('<textarea>'+document.getElementById('result').value+'</textarea>');
		iframeWin.document.close();
		iframeWin.document.charset='utf-8';
		iframeWin.document.execCommand('SaveAs','','*.txt');
	}else{
		alert("Your have to create your Press Release First ")
	}
}

function ShowHide(id){
		if(document.getElementById(id).style.display=="none"){
			document.getElementById(id).style.display=""
		}else{
			document.getElementById(id).style.display="none"
		}
}

var site = "imnewswatch"
function SendMail(mail,subject){
		window.location="mailto:" + mail +"@"+ site + ".com?subject=" + subject;
}

function CheckMail(Mail,Input){
	var MyForm = document.getElementById(Mail);
	var MyInput = document.getElementById(Input);
	if ( document.Friend.Email.value.indexOf ('@', 0) == -1 || document.Friend.Email.value.indexOf ('.', 0) == -1 ) 
	{
		alert("Please enter a valid E-mail");
		document.Friend.Email.focus();
		return;
	}else{
		document.Friend.submit();
	}
}
function CheckSearch(Mail,Input){
	//var MyForm = document.getElementById(Mail);
	///var MyInput = MyForm.elements[Input];
	if ( document.SiteSearch.search.value.length<3) 
	{
		alert("please enter at lease 3 characters");
		document.SiteSearch.search.focus();
		return;
	}else{
		document.SiteSearch.submit();
	}
}
var MyWindow;
function CheckWebSearch(Mail,Input,SearchEngine){
	var test1=false;
	var test2=false;
	//var MyForm = document.getElementById(Mail);
	//var MyInput = MyForm.elements[Input];
	
		switch (SearchEngine)
		{
			/*case "1":
			if (document.WebSearch.google.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.google.focus();
				return;
			}else{
				MyWindow = "http://www.google.com/search?hl=en&q="+document.WebSearch.google.value;
				window.open(MyWindow);
			}
			break;
			*/
			case "1":
			if (document.WebSearch.q.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.q.focus();
				return;
			}else{
				MyWindow = "http://www.google.com/search?hl=en&q="+document.WebSearch.q.value;
				window.open(MyWindow);
			}
			break;

			case "2":
			if (document.WebSearch.q.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.q.focus();
				return;
			}else{
				MyWindow = "http://search.yahoo.com/search?p="+document.WebSearch.q.value+"&fr=FP-tab-web-t&toggle=1&ei=UTF-8";
				window.open(MyWindow);
			}
			break;
			
			case "3":
			if (document.WebSearch.q.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.q.focus();
				return;
			}else{
				MyWindow = "http://search.msn.com/results.aspx?FORM=MSNH&srch_type=0&q="+document.WebSearch.q.value;
				window.open(MyWindow);
			}
			break;
			
			case"4":
			if (document.WebSearch.q.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.q.focus();
				return;
			}else{
				MyWindow = "http://www.altavista.com/web/results?itag=ody&q="+document.WebSearch.q.value+"&kgs=1&kls=0";
				window.open(MyWindow);
			}
			break;
			
			case "5":
			if (document.WebSearch.q.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.q.focus();
				return;
			}else{
				MyWindow = "http://msxml.excite.com/info.xcite/search/web/"+document.WebSearch.q.value;
				window.open(MyWindow);
			}
			break;
			
			case "6":
			if (document.WebSearch.q.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.q.focus();
				return;
			}else{
				MyWindow ="http://search.dmoz.org/cgi-bin/search?search="+document.WebSearch.q.value;
				window.open(MyWindow);
			}
			break;
			
			case "7":
			if (document.WebSearch.q.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.q.focus();
				return;
			}else{
				MyWindow = "http://www.alexa.com/data/details/?url="+document.WebSearch.q.value;
				window.open(MyWindow);
			}
			break;
			
			case "8":
			if (document.WebSearch.amazon.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.amazon.focus();
				return;
			}else{
				MyWindow = "http://www.amazon.com/exec/obidos/search-handle-url/ref=br_ss_hs/103-1352800-4604638?platform=gurupa&url=index%3Dblended&field-keywords="+document.WebSearch.amazon.value+"&Go.x=3&Go.y=12";
				window.open(MyWindow);
			}
			break;
			
			case "9":
			if (document.WebSearch.clickBank.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.clickBank.focus();
				return;
			}else{
				MyWindow = "http://www.clickbank.com/?url="+document.WebSearch.clickBank.value;
				window.open(MyWindow);
			}
			break;
			
			case "10":
			if (document.WebSearch.ebay.value.length<3) {
				alert("please enter at lease 3 characters");
				document.WebSearch.ebay.focus();
				return;
			}else{
				MyWindow = "http://search.ebay.com/"+document.WebSearch.ebay.value+"_W0QQfromZR40QQsojsZ1";
				window.open(MyWindow);
			}
			break;

			default:
			//default;
		}
	}	
////////////////////////////////////////////////////////
//Scrolling News Functions
var AutoScrollInterval;
var c=0;
var Speed="4000";
AutoScroll();
function AutoScroll(){
	AutoScrollInterval = setInterval(ChangeNews,Speed);
}

function ChangeNews(){
	
	if(c<News.length-1){
		c++;
	}else{
		c=0;
	}
	if(navigator.appName.indexOf('Microsoft Internet Explorer')!=-1){
		document.getElementById('NewsScroll').style.filter="progid:DXImageTransform.Microsoft.Fade(overlap=1)";
		document.getElementById('NewsScroll').filters[0].apply();
		document.getElementById('NewsScroll').filters[0].duration=1;
		document.getElementById('NewsScroll').innerHTML = '<a href="'+News[c][1]+'">' + News[c][0] + '</a>';
		document.getElementById('NewsScroll').filters[0].play(1);
	}else{
		document.getElementById('NewsScroll').innerHTML = '<a href="'+News[c][1]+'">' + News[c][0] + '</a>';
	}
}
function PauseNews(){
	document.getElementById('BPlay').style.display='';
	document.getElementById('BPause').style.display='none';
	clearInterval(AutoScrollInterval);
}
function PlayNews(){
	document.getElementById('BPlay').style.display='none';
	document.getElementById('BPause').style.display='';
	AutoScrollInterval = setInterval(ChangeNews,Speed);
}
function NextNews(){
	document.getElementById('BPlay').style.display='';
	document.getElementById('BPause').style.display='none';
	clearInterval(AutoScrollInterval);
	if(c<News.length-1)ChangeNews();
}
function PreviousNews(){
	document.getElementById('BPlay').style.display='';
	document.getElementById('BPause').style.display='none';
	clearInterval(AutoScrollInterval);
	if(c>0){
		c=c-2;
		ChangeNews();
	}
}

//Clock Function
var now = new Date();
var nowUTC = new Date(Date.UTC(now.getFullYear(),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds,now.getMilliseconds()))
var EST = -9 // I have no idea ;-)
var anHour = 60*60*1000;
now.setTime(nowUTC+(EST*anHour));
dg0 = new Image();dg0.src = "images/dg0.gif";
dg1 = new Image();dg1.src = "images/dg1.gif";
dg2 = new Image();dg2.src = "images/dg2.gif";
dg3 = new Image();dg3.src = "images/dg3.gif";
dg4 = new Image();dg4.src = "images/dg4.gif";
dg5 = new Image();dg5.src = "images/dg5.gif";
dg6 = new Image();dg6.src = "images/dg6.gif";
dg7 = new Image();dg7.src = "images/dg7.gif";
dg8 = new Image();dg8.src = "images/dg8.gif";
dg9 = new Image();dg9.src = "images/dg9.gif";
dgam= new Image();dgam.src= "images/dgam.gif";
dgpm= new Image();dgpm.src= "images/dgpm.gif";
dgc = new Image();dgc.src = "images/dgc.gif";

function dotime(){ 
//theTime=setTimeout('dotime()',1000);
d = new Date();
hr= d.getUTCHours();
var TempHr = hr - 4;
if(TempHr<0){
	hr = (23 + TempHr) + 100;
}else{
	hr = TempHr +100;
}
mn= d.getUTCMinutes()+100;
se= d.getUTCSeconds()+100;
if(hr==100){hr=112;am_pm='am';}
else if(hr<112){am_pm='am';}
else if(hr==112){am_pm='pm';}
else if(hr>112){am_pm='pm';hr=(hr-12);}
tot=''+hr+mn+se;
document.hr1.src = 'images/dg'+tot.substring(1,2)+'.gif';
document.hr2.src = 'images/dg'+tot.substring(2,3)+'.gif';
document.mn1.src = 'images/dg'+tot.substring(4,5)+'.gif';
document.mn2.src = 'images/dg'+tot.substring(5,6)+'.gif';
document.se1.src = 'images/dg'+tot.substring(7,8)+'.gif';
document.se2.src = 'images/dg'+tot.substring(8,9)+'.gif';
document.ampm.src= 'images/dg'+am_pm+'.gif';
}

function addBookmarkForBrowser() {
	
	if (document.all){
		//window.external.AddFavorite(document.location.href,"Internet Marketing NewsWatch");
  		document.body.style.behavior='url(#default#homepage)';
  		document.body.setHomePage('http://www.imnewswatch.com');
		
	} else {
		
		/*var ea = document.createEvent("MouseEvents");
		ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
		var eb = document.getElementsByTagName("head")[0];
		eb.ownerDocument getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
		eb.dispatchEvent(ea);
		*/
		window.sidebar.addPanel("http://www.imnewswatch.com", "http://www.imnewswatch.com","");
	}

}


function valid(form) {
  var field = form.subscriber_email;
  var str = field.value;
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
    var reg1 = new RegExp(reg1str);
    var reg2 = new RegExp(reg2str);
    if (!reg1.test(str) && reg2.test(str)) {
		 return true;
    }
    field.focus();
    field.select();
	alert("Please Fill The Valid Email Adress");
	 return false;
  } else {
    if(str.indexOf("@") >= 0)
      return true;
    field.focus();
    field.select();
	alert("Please Fill The Valid Email Adress");
	return false;
  }
}

