// ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
// This software is copyright ? 2006 onwards by SONIK Technologies (www.soniktechnologies.com)
// SONIK Technologies - technical Mobile Web Initiative (MWI) software strategy consultants
// 
// Intellectual property rights and copyright title are vested with SONIK Technologies.
// Title to copyright in this software and any associated documentation will at all times remain
// with the copyright holder.
// 
// This source file may contain confidential information or data and may be Legally Privileged.
// Reproduction is not authorised without prior written agreement from the copyright holder.
// 
// Originally developed by Nischal soni (nischal.soni@soniktechnologies.com) as Project leader 
// for SONIK Technologies.
// ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------

// ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------
// This is version 1.0 of this specific script.
// Created on 15.04.2006 by Kapil Chawla (kapcee_bits@yahoo.co.in)
//
// ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------ ------

function showCurrentDateTime(){
var days = new Object;
var months = new Object;

days[0] = "Sun";
days[1] = "Mon";
days[2] = "Tues";
days[3] = "Wed";
days[4] = "Thu";
days[5] = "Fri";
days[6] = "Sat";

months[0] = "Jan";
months[1] = "Feb";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "Sept";
months[9] = "Oct";
months[10]= "Nov";
months[11]= "Dec";

function GetDate()
{   var date = new Date();

    var year=date.getYear();
    var br=navigator.appVersion;

    if (br.indexOf("3.")==-1)
        year=date.getFullYear();

    return  days[date.getDay()] +" "+
            date.getDate() +" "+
            months[date.getMonth()] +", "+
            year;
}

        Stamp = new Date();
        document.write();
        var Hours;
        var Mins;
        var Time;
        Hours = Stamp.getHours();
        if (Hours >= 12) {
                Time = " pm";
        }
        else {
                Time = " am";
        }

        if (Hours > 12) {
                Hours -= 12;
        }
        if (Hours == 0) {
                Hours = 12;
        }
        Mins = Stamp.getMinutes();
        if (Mins < 10) {
                Mins = "0" + Mins;
        }

        document.write("" + Hours + ":" + Mins + Time + ", ");

        document.write(GetDate());
		}//end of function


//check session and forward to ad new page
function alertPopup(sessflag){

if(sessflag)
	location.href="http://www.autotxttrader.com/index.php?show=new_ad";
else
	{alert("You must login or register to use this feature");
	location.href="http://www.autotxttrader.com/index.php?show=login";
	}
}

function alert_systemabuse(sessflag1){

if(sessflag1)
	location.href="http://www.autotxttrader.com/index.php?show=system_abuse";
else
	{alert("You must login or register to use this feature");
	location.href="http://www.autotxttrader.com/index.php?show=login";
	}

}

//=============================================================================
//FUNCTION WILL SET THE VALUE IN PARENT DOCUMENT FROM THE CHILD IFRAME DOCUMENT
//=============================================================================
function setMainModel(parentid,value)
{
	parent.document.getElementById(parentid).value = value;
}
//============================================================
//SET THE VALUES ACCORDING TO THE SELECTED PRODUCT/PORTFOLIO
//============================================================

function setCategoryValue(SelId)
{
var Arylen = CatIdAry.length;


var CatOptionsAry = new Array();

var proid ='';
var catid ='';

	//HAS THE PROID OF CALLER PROD OR PORT
	CallProid = SelId.split("|");
var OptionText = '';

var catCnt=0;
for(var cnt = 0; cnt < Arylen; cnt++)
{
	//MAIN ARRAY OF ALL ITEMS FROM ITEM TABLE
	//WHICH HAVE THE PROID,CATID,CATNAME
	MainProid = CatIdAry[cnt].split("#");
	
	
	if(CallProid[3] == MainProid[0])
	{
	
	OptionText = OptionText+"<option value='"+MainProid[1]+"|"+MainProid[2]+"'>"+MainProid[2]+"</option>";
	}
}
OptionText = "<select name='callercategory' id='callercategorycomboid' style='background-color: #DAE8FC;'><option value=''>Please select</option>"+OptionText+"</select>";

document.getElementById("catmainid").innerHTML= OptionText;
}

//========================================================
//Function to submit the iframe by passing some arguments
//========================================================
function submitIframe(frameid,idvalue,hidid)
{
		
	document.getElementById(frameid).src="./admin/model.php?catid="+idvalue+"&hidid="+hidid;
	document.getElementById(frameid).submit(); 
		
}


function CheckEmailId(val) {
		// Check for a properly formatted email address.
		   if ((val.value.length == 0)) {
		
			  return false;
		
		   }
		alert(val.value.length);
		   if (val.value.length != 0) {
		
			 // var emailformat = /^.+@.+\..{2,3}$/;
		
			 var emailformat = /^[^@\s]+@([-a-z0-9]+\.)+([a-z]{2}|com|net|edu|org|gov|mil|int|biz|pro|info|arpa|aero|coop|name|museum|nic|in|co.in|co|inc)$/;
		
			  if (!emailformat.test(val.value))
		
			   {
		
				 alert("Please enter a valid email-Id");
		
				 val.value="";
		
				 val.focus();
		
				 return false;
		
			  }
		
		   }
		
		   return true;
		
		}
function checkForm()
{
	with(window.document.loginform)
	{
		if(username.value=="" || password.value=="")
		{
			alert("Please Enter User Name and Password.");
			return false;
		}
	}
	return true;
}
		//===============================================================================================================================
