var	projectPath="/";
var	guestSchoolSubmission="Y";
var	guestForuumSubmission="Y";

var	globalVariable1="";
var	globalVariable2="";
var	globalVariable3="";
var	globalVariable4="";
var	globalVariable5="";
var	globalVariable6="";
			
function SEKeyPAction(this1,eve)
{
	var keycode = "";
	if (window.event) keycode = window.event.keyCode;
		else if (eve) keycode = eve.which;
	else 
		return true;
	if (keycode == 13)
	{
		try{
		SEKeyPActionImpl();
		}catch(e){
		
		}
		
		eve.returnValue=false;
		return false;
	}
	else{
		return true;
	}
}

function SEKeyPNoAction(this1,eve)
{
	var keycode = "";
	if (window.event) keycode = window.event.keyCode;
		else if (eve) keycode = eve.which;
	else 
		return true;
	if (keycode == 13)
	{
		return false;
	}
	else{
		return true;
	}
}


function SMK_KeyPress(obj) {
    var sndr = window.event.srcElement;
    var key = window.event.keyCode;
    var char = String.fromCharCode(key);

	//alert('val: '+obj.value);
	if(obj.value!=null && (obj.value =='' || obj.value =='select' || obj.value =='Select' || obj.value =='All' || obj.value =='ALL') ){
		sndr.smk_keystrokes = "";
	}
    var sysdate = new Date();
    // if the last key press was more than 2 seconds ago, reset the keystrokes
    if(sndr.smk_lastpresstime=="" || sysdate.getTime()-sndr.smk_lastpresstime>800) {
        sndr.smk_keystrokes = "";
    }
    sndr.smk_lastpresstime = sysdate.getTime();
    // set up a regular expression for comparing with list box entries
    var re = new RegExp("^" + sndr.smk_keystrokes + char, "i");        // "i" -> ignoreCase
    // check each list box item for a match
    for(var i=0; i<sndr.options.length; i++) {
		//This condition is added By Laxmiaknth on 10/10/2007.
		if(sndr.options[i].text!='Select' && sndr.options[i].text!='select' && sndr.options[i].text!='ALL' && sndr.options[i].text!='All'){
			if(re.test(sndr.options[i].text)) {
				sndr.options[i].selected=true;
				sndr.smk_keystrokes += char;
				
				break;
			}
		}
    }
    // sink the keypress, ie don't pass it on to Windows or anything else
    window.event.returnValue = false;
}






 function trim ( s) {
    return s.replace(/^\s*/, "").replace(/\s*$/, "");
}

function replaceEditorHtmlforValidate(s){
var validatereview = s;
    validatereview = validatereview.replace(/<br>/g,'');
   validatereview = validatereview.replace(/<p>/g,'');
   validatereview = validatereview.replace(/<\/p>/g,'');
 validatereview = validatereview.replace(/<P>/g,'');
   validatereview = validatereview.replace(/<\/P>/g,'');
 validatereview = validatereview.replace(/<div>/g,'');
   validatereview = validatereview.replace(/<\/div>/g,'');
  validatereview = validatereview.replace(/&nbsp;/g,'');
 return  validatereview;
 }
 
 function decodeEditorHtml(s){

    s = s.replace(/&/g,'3e');
 return  s;
 }
 

function isLoggedIn(){

//alert("kk"+projectPath)
var ajaxUrl=projectPath+"articManager.do?method=isloginOrNot"
//alert(ajaxUrl)
var out= callAjax(ajaxUrl)

var logedIn;
if(out=='Y'){
logedIn=true;
}else{
logedIn=false;
}

return  logedIn;
}


function clickLinkEdit( link){
document.location = link;
}



function clickLink( link){
document.location = link;
}

function onKeyDown() {

  // current pressed key
  var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();

  //if (event.ctrlKey && (pressedKey == "c" || 
  //                      pressedKey == "v")) {alert("No")
	if (event.ctrlKey && (pressedKey == "c" 
                       )) {
                       //alert("No")
					//	alert("copy not allowed")
    // <strong class="highlight">disable</strong> key press porcessing
    event.returnValue = false;
  }

} 


// failed
function transTeluguToENG(sourceENGText ,destTextBox) {
 google.load("language", "1");
//sourceENGText="jag"

	alert("transTeluguToENG"+sourceENGText)
    alert(destTextBox)
    destTextBox.value ="jjjj"
      google.language.transliterate([sourceENGText], "en", "te", function(result) {
        if (!result.error) {
         // var destTextBox = document.getElementById(destText);
          if (result.transliterations && result.transliterations.length > 0 &&
            result.transliterations[0].transliteratedWords.length > 0) {
        //    alert(result.transliterations[0].transliteratedWords[0])
         destTextBox.value = 'result.transliterations[0].transliteratedWords[0]';
        //   return result.transliterations[0].transliteratedWords[0];
          }
        }
      });
    }



function smallLoginPopUp(){
wnd = window.open(projectPath+"loginRegister.do?method=smallLogin"
			,"log",'width=400,height=490,left=15,top=15');
			
			}




function  processArticText(articText){
var processedArticText='';

processedArticText=articText.replace(/\r\n|\r|\n/g,'<br>');
processedArticText=processedArticText.replace(/  /g,'&nbsp&nbsp')
return processedArticText
}



 function reProcessArticText(articText){
var processedArticText=articText.replace(/\<br(\s*\/|)\>/g,'\n');
 processedArticText=processedArticText.replace('&nbsp',' ');

return processedArticText;
}


function isEmailValid( emailid)	{
	email = emailid
	if(email.indexOf("@") > 0 && email.indexOf(".") > 0 )	{
		atCount = 0 
		dotCount = 0
		for(i=0;i<email.length;i++)	{
			if(email.charAt(i) == "@")	atCount = atCount+1
			else if(email.charAt(i) == ".") dotCount = dotCount+1	
		}
		if(atCount < 2)	{
			for(i=email.indexOf("@");i<email.length;i++)	{
				if(email.charAt(i) == ".")
					if(! ((email.indexOf("@")+1) == i) )
						return true	
			}
		}	
	}
	alert("Invalid Email. Ex. name@domain.com")
//document.loginOrRegisterForm.emailid.focus
		
	return false
}

// SCHOOLs


function validateSchoolColgeLogin(){

logedIn=isLoggedIn();

if(guestSchoolSubmission=='N'){
if(!logedIn){
alert("Please Login To Submit the Article");
smallLoginPopUp()
			return false;
			}
			
}
// else

var  userContinue=true;
if(!logedIn){
  userContinue= confirm("You are not LoggedIn to Submit a New Article .Do You Want to Submit with out Login.")
smallLoginPopUp()

}


if(!userContinue){
return false;
} else
return true;


}

// review
function validateReviewLogin(){

logedIn=isLoggedIn();

if(guestSchoolSubmission=='N'){
if(!logedIn){
alert("Please Login To Submit the Review");
smallLoginPopUp()
			return false;
			}
			
}
// else

var  userContinue=true;
if(!logedIn){
  userContinue= confirm("You are not LoggedIn to Submit Review .Do You Want to Submit with out Login.")
smallLoginPopUp()

}


if(!userContinue){
return false;
} else
return true;


}






// forum
function validateForumLogin(){

logedIn=isLoggedIn();

if(guestForuumSubmission=='N'){
if(!logedIn){
alert("Please Login To Participate  in Forum");
smallLoginPopUp()
			return false;
			}
			
}
// else

var  userContinue=true;
if(!logedIn){
  userContinue= confirm("You are not LoggedIn  .Do You Want to Participate in Forum with out Login.")
smallLoginPopUp()

}


if(!userContinue){
return false;
} else
return true;


}





// END SCHOOLS




















// validations

function isInteger (i) {
	return (i.toString().search(/^-?[0-9]+$/) == 0 )
}




















function relNoFollow()
{

	var FkLinks = document.getElementsByTagName('span');
	//alert(FkLinks.length)
	if( FkLinks.length > 0 )
	{
		for( var i = 0; i < FkLinks.length; i++ )
		{
			if( FkLinks[i].id.indexOf( 'open' ) != -1||FkLinks[i].id.indexOf( 'js' ) != -1 ||FkLinks[i].id.indexOf( 'link' ) != -1)
			{
			
				FkLinks[i].onmouseout 	= fklinkMouseOut;
				FkLinks[i].onmouseover 	= fklinkMouseOver;
				FkLinks[i].onclick 		= fklinkClick;
			}
		}
	}
}

function fklinkMouseOver()
{
//	this.className = 'fklink-hover';
	//this.className = 'fklink';
	
}

function fklinkMouseOut()
{
	//this.className = 'fklink';
}

function fklinkClick()
{
 var title=this.id;
var link=this.title;

//alert(link+title)
if(title.indexOf( 'open' ) != -1){
var FkLinkWindow = window.open( link, 'outbound', '' );
}
else
    if(title.indexOf( 'link' ) != -1){
	document.location=link;
	}
	else
    if(title.indexOf( 'js' ) != -1){
    //Sid.spplit("
   // window["link"](); 
	eval(link)
	}
	
}


