var gtvt_main={
getCookieVal:function(offset){
var endstr=document.cookie.indexOf(";",offset);
if(endstr==-1){
endstr=document.cookie.length;}
return unescape(document.cookie.substring(offset,endstr));},
GetCookie:function(name){
var arg=name+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while(i<clen){
var j=i+alen;
if(document.cookie.substring(i,j)==arg){
return this.getCookieVal(j);}
i=document.cookie.indexOf(" ",i)+1;
if(i==0){break;}}
return null;},
SetCookie:function(name,value){
var argv=this.SetCookie.arguments;
var argc=this.SetCookie.arguments.length;
var expires=(argc>2)?argv[2]:null;
var path=(argc>3)?argv[3]:null;
var domain=(argc>4)?argv[4]:null;
var secure=(argc>5)?argv[5]:false;
document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");},
get_data:function(){
document.forms.gtvtForm.email.focus();
var loginOptions=this.GetCookie("so");
if(loginOptions==null){loginOptions="";}
if(loginOptions.length<=0){loginOptions="";}
//document.forms.gtvtForm.loginOptions.value=loginOptions;
if(loginOptions=="3"){
document.forms.gtvtForm.loginOptions.checked="checked";}
var emailId=this.GetCookie("si");
if(emailId!=null && emailId!==''){
document.forms.gtvtForm.email.value=emailId;
if(document.forms.gtvtForm.password!=null){
document.forms.gtvtForm.password.focus();}}
var openIdURL=this.GetCookie("soi");
  if (openIdURL != null ) 
      document.forms.gtvtForm.openid.value = openIdURL;},
submitForm:function(formAction){
document.forms.gtvtForm.action=formAction;
document.forms.gtvtForm.submit();},
filterEmailIds:function(){
var emailIds="";
var count=0;
var contactId="";
var fieldName="";
var size=0;
var inputs=document.getElementsByTagName("input");
if(inputs&&inputs.length){
size=inputs.length;}
for(i=0;i<size;i++){
if(inputs[i].type=='checkbox'&&inputs[i].checked){
count=count+1;
if(inputs[i].value!='false'){
contactId=inputs[i].value;
fieldName="checkedId_"+contactId;
if(navigator.appName=="Netscape"){
if(document.forms.gtvtForm.elements[fieldName]&&document.forms.gtvtForm.elements[fieldName].value){
emailIds=emailIds+document.forms.gtvtForm.elements[fieldName].value+", ";}}else{
if(document.gtvtForm(fieldName)&&document.gtvtForm(fieldName).value){
emailIds=emailIds+document.gtvtForm(fieldName).value+", ";}}}}}
if(count==0){
alert("No Contact selected for emailing.");return true;}
if(emailIds==""){
alert("Selected groups do not have any emailIds.");return true;}
var emailValue=window.opener.document.forms.gtvtForm.to.value;
var emailIdsSub="";
var lastIndex=emailIds.lastIndexOf(", ");
if(lastIndex>0){
emailIdsSub=emailIds.substring(0,lastIndex);}
if(emailValue&&emailValue.length>0){
window.opener.document.forms.gtvtForm.to.value=window.opener.document.forms.gtvtForm.to.value+","+emailIdsSub;}else{
window.opener.document.forms.gtvtForm.to.value=emailIdsSub;}
window.close();},
popupClose:function(){
if(window.opener&&!window.opener.closed){
window.opener.document.gtvtForm.to.focus();
window.close();}}};

